Removed broken AmigaOS support. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Sun, 29 Oct 2006 03:58:27 +0000
branchSDL-1.2
changeset 38886d2e1961661a
parent 3887 9dcceea84416
child 3889 67d518069d9a
Removed broken AmigaOS support.

Fixes Bugzilla #337.
BUGS
README
README.AmigaOS
include/SDL_config.h.default
include/SDL_config.h.in
include/SDL_config_amiga.h
include/SDL_platform.h
src/audio/SDL_audio.c
src/audio/amigaos/SDL_ahiaudio.c
src/audio/amigaos/SDL_ahiaudio.h
src/joystick/amigaos/SDL_sysjoystick.c
src/thread/SDL_thread_c.h
src/thread/amigaos/SDL_syssem.c
src/thread/amigaos/SDL_systhread.c
src/thread/amigaos/SDL_systhread_c.h
src/thread/amigaos/SDL_thread.c
src/timer/amigaos/SDL_systimer.c
src/video/SDL_video.c
src/video/cybergfx/SDL_amigaevents.c
src/video/cybergfx/SDL_amigaevents_c.h
src/video/cybergfx/SDL_amigamouse.c
src/video/cybergfx/SDL_amigamouse_c.h
src/video/cybergfx/SDL_cgxaccel.c
src/video/cybergfx/SDL_cgxgl.c
src/video/cybergfx/SDL_cgxgl_c.h
src/video/cybergfx/SDL_cgximage.c
src/video/cybergfx/SDL_cgximage_c.h
src/video/cybergfx/SDL_cgxmodes.c
src/video/cybergfx/SDL_cgxmodes_c.h
src/video/cybergfx/SDL_cgxvideo.c
src/video/cybergfx/SDL_cgxvideo.h
src/video/cybergfx/SDL_cgxwm.c
src/video/cybergfx/SDL_cgxwm_c.h
test/testplatform.c
     1.1 --- a/BUGS	Sun Oct 29 03:44:25 2006 +0000
     1.2 +++ b/BUGS	Sun Oct 29 03:58:27 2006 +0000
     1.3 @@ -190,15 +190,3 @@
     1.4  	More information on this port is available at:
     1.5  	http://www.kom.e-technik.tu-darmstadt.de/~griff/SDL/
     1.6  
     1.7 -AmigaOS:  -= NOT YET SUPPORTED =-
     1.8 -	The OpenGL support isn't implemented yet.
     1.9 -
    1.10 -	SDL_WM_GrabInput() is not implemented.
    1.11 -	Does anyone know how to do this?  SDL_WM_GrabInput() is designed
    1.12 -	to prevent the user from switching input and mouse focus away from
    1.13 -	the SDL application.
    1.14 -
    1.15 -	Continuous relative mouse motion is not implemented.
    1.16 -
    1.17 -	The AmigaOS port was done by Gabriele.Greco@galactica.it
    1.18 -
     2.1 --- a/README	Sun Oct 29 03:44:25 2006 +0000
     2.2 +++ b/README	Sun Oct 29 03:58:27 2006 +0000
     2.3 @@ -14,7 +14,7 @@
     2.4  
     2.5  The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
     2.6  Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
     2.7 -The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64,
     2.8 +The code contains support for Dreamcast, Atari, AIX, OSF/Tru64,
     2.9  RISC OS, SymbianOS, and OS/2, but these are not officially supported.
    2.10  
    2.11  SDL is written in C, but works with C++ natively, and has bindings to
     3.1 --- a/README.AmigaOS	Sun Oct 29 03:44:25 2006 +0000
     3.2 +++ b/README.AmigaOS	Sun Oct 29 03:58:27 2006 +0000
     3.3 @@ -1,50 +1,12 @@
     3.4 -This is the porting of 1.2.0 version of SDL (the latest stable one)
     3.5 -to AmigaOS/68k.
     3.6 +The AmigaOS code has been removed from SDL, since it had been broken for a
     3.7 + long time and had a few bits of fairly invasive code #ifdef'd into the
     3.8 + SDL core.
     3.9  
    3.10 -All the bugs known of the past version have been corrected. And I've
    3.11 -added all the new SDL features.
    3.12 +However, there is an OS4 version of SDL here:
    3.13 +   http://www.rcdrummond.net/amiga/index.html
    3.14  
    3.15 -This version of SDL needs Cybergraphx V3 (r69+) or CyberGraphX V4
    3.16 -and AHI v3+. Probably it works also with P96 or CGXAga, but it's 
    3.17 -untested.
    3.18 +And a MorphOS version here:
    3.19 +   http://www.lehtoranta.net/powersdl/
    3.20  
    3.21 -This version is available as linked library for SAS/C and GCC, only 68k this 
    3.22 -time, a powerup (ppcemu compatible) and a morphos version will be ready quite 
    3.23 -soon (i hope).
    3.24 +--ryan.
    3.25  
    3.26 -Implemented:
    3.27 -
    3.28 -- 8/16/24/32bit video modes, both fullscreen and windowed.
    3.29 -- Hardware surfaces.
    3.30 -- CGX blitting acceleration.
    3.31 -- CGX colorkey blitting acceleration.
    3.32 -- AHI audio (8/16 bit, with any audio format), always uses unit 0 for now.
    3.33 -- Thread support (maybe not 100% compatible with other implementations)
    3.34 -- Semaphores 
    3.35 -- Window resizing and backdrop windows (NEW)
    3.36 -- Joystick/Joypad support.
    3.37 -
    3.38 -To do:
    3.39 -
    3.40 -- CDRom audio playing support
    3.41 -- OpenGL (A guy was working on it but I've lost his tracks :( )
    3.42 -
    3.43 -The SAS/C library is distributed with debug info attached, to strip debug info 
    3.44 -simply add STRIPDEBUG argument to the linker.
    3.45 -
    3.46 -NOTE: SDL includes debug output using kprintf, to disable it add to your 
    3.47 -project a function like this:
    3.48 -
    3.49 -void kprintf(char *a,...)
    3.50 -{
    3.51 -}
    3.52 -
    3.53 -Otherwise you can redirect the debug to a console window with sushi, sashimi or
    3.54 -similar tools (the default output is the internal serial port). 
    3.55 -
    3.56 -For info, support, bugfix and other feel free to mail me:
    3.57 -
    3.58 -Gabriele Greco (gabriele.greco@aruba.it)
    3.59 -
    3.60 -You can find also a small SDL Amiga page at:
    3.61 -http://ggreco.interfree.it/sdl.html
     4.1 --- a/include/SDL_config.h.default	Sun Oct 29 03:44:25 2006 +0000
     4.2 +++ b/include/SDL_config.h.default	Sun Oct 29 03:58:27 2006 +0000
     4.3 @@ -26,9 +26,7 @@
     4.4  #include "SDL_platform.h"
     4.5  
     4.6  /* Add any platform that doesn't build using the configure system */
     4.7 -#if defined(__AMIGA__)
     4.8 -#include "SDL_config_amiga.h"
     4.9 -#elif defined(__DREAMCAST__)
    4.10 +#if defined(__DREAMCAST__)
    4.11  #include "SDL_config_dreamcast.h"
    4.12  #elif defined(__MACOS__)
    4.13  #include "SDL_config_macos.h"
     5.1 --- a/include/SDL_config.h.in	Sun Oct 29 03:44:25 2006 +0000
     5.2 +++ b/include/SDL_config.h.in	Sun Oct 29 03:58:27 2006 +0000
     5.3 @@ -195,7 +195,6 @@
     5.4  
     5.5  /* Enable various input drivers */
     5.6  #undef SDL_INPUT_TSLIB
     5.7 -#undef SDL_JOYSTICK_AMIGA
     5.8  #undef SDL_JOYSTICK_BEOS
     5.9  #undef SDL_JOYSTICK_DC
    5.10  #undef SDL_JOYSTICK_DUMMY
    5.11 @@ -221,7 +220,6 @@
    5.12  #undef SDL_LOADSO_WIN32
    5.13  
    5.14  /* Enable various threading systems */
    5.15 -#undef SDL_THREAD_AMIGA
    5.16  #undef SDL_THREAD_BEOS
    5.17  #undef SDL_THREAD_DC
    5.18  #undef SDL_THREAD_EPOC
    5.19 @@ -234,7 +232,6 @@
    5.20  #undef SDL_THREAD_WIN32
    5.21  
    5.22  /* Enable various timer systems */
    5.23 -#undef SDL_TIMER_AMIGA
    5.24  #undef SDL_TIMER_BEOS
    5.25  #undef SDL_TIMER_DC
    5.26  #undef SDL_TIMER_DUMMY
     6.1 --- a/include/SDL_config_amiga.h	Sun Oct 29 03:44:25 2006 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,80 +0,0 @@
     6.4 -/*
     6.5 -    SDL - Simple DirectMedia Layer
     6.6 -    Copyright (C) 1997-2006 Sam Lantinga
     6.7 -
     6.8 -    This library is free software; you can redistribute it and/or
     6.9 -    modify it under the terms of the GNU Lesser General Public
    6.10 -    License as published by the Free Software Foundation; either
    6.11 -    version 2.1 of the License, or (at your option) any later version.
    6.12 -
    6.13 -    This library is distributed in the hope that it will be useful,
    6.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 -    Lesser General Public License for more details.
    6.17 -
    6.18 -    You should have received a copy of the GNU Lesser General Public
    6.19 -    License along with this library; if not, write to the Free Software
    6.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 -
    6.22 -    Sam Lantinga
    6.23 -    slouken@libsdl.org
    6.24 -*/
    6.25 -
    6.26 -#ifndef _SDL_config_amiga_h
    6.27 -#define _SDL_config_amiga_h
    6.28 -
    6.29 -#include "SDL_platform.h"
    6.30 -
    6.31 -/* This is a set of defines to configure the SDL features */
    6.32 -
    6.33 -#define SDL_HAS_64BIT_TYPE	1
    6.34 -
    6.35 -/* Useful headers */
    6.36 -#define HAVE_SYS_TYPES_H	1
    6.37 -#define HAVE_STDIO_H	1
    6.38 -#define STDC_HEADERS	1
    6.39 -#define HAVE_STRING_H	1
    6.40 -#define HAVE_INTTYPES_H	1
    6.41 -#define HAVE_SIGNAL_H	1
    6.42 -
    6.43 -/* C library functions */
    6.44 -#define HAVE_MALLOC	1
    6.45 -#define HAVE_CALLOC	1
    6.46 -#define HAVE_REALLOC	1
    6.47 -#define HAVE_FREE	1
    6.48 -#define HAVE_ALLOCA	1
    6.49 -#define HAVE_GETENV	1
    6.50 -#define HAVE_PUTENV	1
    6.51 -#define HAVE_MEMSET	1
    6.52 -#define HAVE_MEMCPY	1
    6.53 -#define HAVE_MEMMOVE	1
    6.54 -#define HAVE_MEMCMP	1
    6.55 -
    6.56 -/* Enable various audio drivers */
    6.57 -#define SDL_AUDIO_DRIVER_AHI	1
    6.58 -#define SDL_AUDIO_DRIVER_DISK	1
    6.59 -#define SDL_AUDIO_DRIVER_DUMMY	1
    6.60 -
    6.61 -/* Enable various cdrom drivers */
    6.62 -#define SDL_CDROM_DUMMY	1
    6.63 -
    6.64 -/* Enable various input drivers */
    6.65 -#define SDL_JOYSTICK_AMIGA	1
    6.66 -
    6.67 -/* Enable various shared object loading systems */
    6.68 -#define SDL_LOADSO_DUMMY	1
    6.69 -
    6.70 -/* Enable various threading systems */
    6.71 -#define SDL_THREAD_AMIGA	1
    6.72 -
    6.73 -/* Enable various timer systems */
    6.74 -#define SDL_TIMER_AMIGA	1
    6.75 -
    6.76 -/* Enable various video drivers */
    6.77 -#define SDL_VIDEO_DRIVER_CYBERGRAPHICS	1
    6.78 -#define SDL_VIDEO_DRIVER_DUMMY	1
    6.79 -
    6.80 -/* Enable OpenGL support */
    6.81 -#define SDL_VIDEO_OPENGL	1
    6.82 -
    6.83 -#endif /* _SDL_config_amiga_h */
     7.1 --- a/include/SDL_platform.h	Sun Oct 29 03:44:25 2006 +0000
     7.2 +++ b/include/SDL_platform.h	Sun Oct 29 03:58:27 2006 +0000
     7.3 @@ -29,10 +29,6 @@
     7.4  #undef __AIX__
     7.5  #define __AIX__		1
     7.6  #endif
     7.7 -#if defined(AMIGA) || defined(__AMIGA) || defined(__amigados__)
     7.8 -#undef __AMIGA__
     7.9 -#define __AMIGA__	1
    7.10 -#endif
    7.11  #if defined(__BEOS__)
    7.12  #undef __BEOS__
    7.13  #define __BEOS__	1
     8.1 --- a/src/audio/SDL_audio.c	Sun Oct 29 03:44:25 2006 +0000
     8.2 +++ b/src/audio/SDL_audio.c	Sun Oct 29 03:58:27 2006 +0000
     8.3 @@ -82,9 +82,6 @@
     8.4  #if SDL_AUDIO_DRIVER_SNDMGR
     8.5  	&SNDMGR_bootstrap,
     8.6  #endif
     8.7 -#if SDL_AUDIO_DRIVER_AHI
     8.8 -	&AHI_bootstrap,
     8.9 -#endif
    8.10  #if SDL_AUDIO_DRIVER_MINT
    8.11  	&MINTAUDIO_GSXB_bootstrap,
    8.12  	&MINTAUDIO_MCSN_bootstrap,
    8.13 @@ -115,10 +112,6 @@
    8.14  int SDL_AudioInit(const char *driver_name);
    8.15  void SDL_AudioQuit(void);
    8.16  
    8.17 -#if SDL_AUDIO_DRIVER_AHI
    8.18 -static int audio_configured = 0;
    8.19 -#endif
    8.20 -
    8.21  /* The general mixing thread function */
    8.22  int SDLCALL SDL_RunAudio(void *audiop)
    8.23  {
    8.24 @@ -128,21 +121,6 @@
    8.25  	void  *udata;
    8.26  	void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len);
    8.27  	int    silence;
    8.28 -#if SDL_AUDIO_DRIVER_AHI
    8.29 -	int started = 0;
    8.30 -
    8.31 -/* AmigaOS NEEDS that the audio driver is opened in the thread that uses it! */
    8.32 -
    8.33 -	D(bug("Task audio started audio struct:<%lx>...\n",audiop));
    8.34 -
    8.35 -	D(bug("Before Openaudio..."));
    8.36 -	if(audio->OpenAudio(audio, &audio->spec)==-1)
    8.37 -	{
    8.38 -		D(bug("Open audio failed...\n"));
    8.39 -		return(-1);
    8.40 -	}
    8.41 -	D(bug("OpenAudio...OK\n"));
    8.42 -#endif
    8.43  
    8.44  	/* Perform any thread setup */
    8.45  	if ( audio->ThreadInit ) {
    8.46 @@ -154,14 +132,6 @@
    8.47  	fill  = audio->spec.callback;
    8.48  	udata = audio->spec.userdata;
    8.49  
    8.50 -#if SDL_AUDIO_DRIVER_AHI
    8.51 -	audio_configured = 1;
    8.52 -
    8.53 -	D(bug("Audio configured... Checking for conversion\n"));
    8.54 -	SDL_mutexP(audio->mixer_lock);
    8.55 -	D(bug("Semaphore obtained...\n"));
    8.56 -#endif
    8.57 -
    8.58  	if ( audio->convert.needed ) {
    8.59  		if ( audio->convert.src_format == AUDIO_U8 ) {
    8.60  			silence = 0x80;
    8.61 @@ -174,11 +144,6 @@
    8.62  		stream_len = audio->spec.size;
    8.63  	}
    8.64  
    8.65 -#if SDL_AUDIO_DRIVER_AHI
    8.66 -	SDL_mutexV(audio->mixer_lock);
    8.67 -	D(bug("Entering audio loop...\n"));
    8.68 -#endif
    8.69 -
    8.70  #ifdef __OS2__
    8.71          /* Increase the priority of this thread to make sure that
    8.72             the audio will be continuous all the time! */
    8.73 @@ -253,14 +218,6 @@
    8.74  		audio->WaitDone(audio);
    8.75  	}
    8.76  
    8.77 -#if SDL_AUDIO_DRIVER_AHI
    8.78 -	D(bug("WaitAudio...Done\n"));
    8.79 -
    8.80 -	audio->CloseAudio(audio);
    8.81 -
    8.82 -	D(bug("CloseAudio..Done, subtask exiting...\n"));
    8.83 -	audio_configured = 0;
    8.84 -#endif
    8.85  #ifdef __OS2__
    8.86  #ifdef DEBUG_BUILD
    8.87          printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID());
    8.88 @@ -532,33 +489,12 @@
    8.89  	audio->enabled = 1;
    8.90  	audio->paused  = 1;
    8.91  
    8.92 -#if !SDL_AUDIO_DRIVER_AHI
    8.93 -
    8.94 -/* AmigaOS opens audio inside the main loop */
    8.95  	audio->opened = audio->OpenAudio(audio, &audio->spec)+1;
    8.96  
    8.97  	if ( ! audio->opened ) {
    8.98  		SDL_CloseAudio();
    8.99  		return(-1);
   8.100  	}
   8.101 -#else
   8.102 -	D(bug("Locking semaphore..."));
   8.103 -	SDL_mutexP(audio->mixer_lock);
   8.104 -
   8.105 -
   8.106 -	audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
   8.107 -	D(bug("Created thread...\n"));
   8.108 -
   8.109 -	if ( audio->thread == NULL ) {
   8.110 -		SDL_mutexV(audio->mixer_lock);
   8.111 -		SDL_CloseAudio();
   8.112 -		SDL_SetError("Couldn't create audio thread");
   8.113 -		return(-1);
   8.114 -	}
   8.115 -
   8.116 -	while(!audio_configured)
   8.117 -		SDL_Delay(100);
   8.118 -#endif
   8.119  
   8.120  	/* If the audio driver changes the buffer size, accept it */
   8.121  	if ( audio->spec.samples != desired->samples ) {
   8.122 @@ -602,7 +538,6 @@
   8.123  		}
   8.124  	}
   8.125  
   8.126 -#if !SDL_AUDIO_DRIVER_AHI
   8.127  	/* Start the audio thread if necessary */
   8.128  	switch (audio->opened) {
   8.129  		case  1:
   8.130 @@ -624,11 +559,6 @@
   8.131  			/* The audio is now playing */
   8.132  			break;
   8.133  	}
   8.134 -#else
   8.135 -	SDL_mutexV(audio->mixer_lock);
   8.136 -	D(bug("SDL_OpenAudio USCITA...\n"));
   8.137 -
   8.138 -#endif
   8.139  
   8.140  	return(0);
   8.141  }
   8.142 @@ -702,12 +632,10 @@
   8.143  			SDL_FreeAudioMem(audio->convert.buf);
   8.144  
   8.145  		}
   8.146 -#if !SDL_AUDIO_DRIVER_AHI
   8.147  		if ( audio->opened ) {
   8.148  			audio->CloseAudio(audio);
   8.149  			audio->opened = 0;
   8.150  		}
   8.151 -#endif
   8.152  		/* Free the driver data */
   8.153  		audio->free(audio);
   8.154  		current_audio = NULL;
     9.1 --- a/src/audio/amigaos/SDL_ahiaudio.c	Sun Oct 29 03:44:25 2006 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,340 +0,0 @@
     9.4 -/*
     9.5 -    SDL - Simple DirectMedia Layer
     9.6 -    Copyright (C) 1997-2006 Sam Lantinga
     9.7 -
     9.8 -    This library is free software; you can redistribute it and/or
     9.9 -    modify it under the terms of the GNU Lesser General Public
    9.10 -    License as published by the Free Software Foundation; either
    9.11 -    version 2.1 of the License, or (at your option) any later version.
    9.12 -
    9.13 -    This library is distributed in the hope that it will be useful,
    9.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 -    Lesser General Public License for more details.
    9.17 -
    9.18 -    You should have received a copy of the GNU Lesser General Public
    9.19 -    License along with this library; if not, write to the Free Software
    9.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    9.21 -
    9.22 -    Sam Lantinga
    9.23 -    slouken@libsdl.org
    9.24 -*/
    9.25 -#include "SDL_config.h"
    9.26 -
    9.27 -/* Allow access to a raw mixing buffer (for AmigaOS) */
    9.28 -
    9.29 -#include "SDL_audio.h"
    9.30 -#include "../SDL_audio_c.h"
    9.31 -#include "SDL_ahiaudio.h"
    9.32 -
    9.33 -/* Audio driver functions */
    9.34 -static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec);
    9.35 -static void AHI_WaitAudio(_THIS);
    9.36 -static void AHI_PlayAudio(_THIS);
    9.37 -static Uint8 *AHI_GetAudioBuf(_THIS);
    9.38 -static void AHI_CloseAudio(_THIS);
    9.39 -
    9.40 -#ifndef __SASC
    9.41 -	#define mymalloc(x) AllocVec(x,MEMF_PUBLIC) 
    9.42 -	#define myfree FreeVec
    9.43 -#else
    9.44 -	#define mymalloc malloc
    9.45 -	#define myfree free
    9.46 -#endif
    9.47 -
    9.48 -/* Audio driver bootstrap functions */
    9.49 -
    9.50 -static int Audio_Available(void)
    9.51 -{
    9.52 -	int ok=0;
    9.53 -	struct MsgPort *p;
    9.54 -	struct AHIRequest *req;
    9.55 -
    9.56 -	if(p=CreateMsgPort())
    9.57 -	{
    9.58 -		if(req=(struct AHIRequest *)CreateIORequest(p,sizeof(struct AHIRequest)))
    9.59 -		{
    9.60 -			req->ahir_Version=4;
    9.61 -
    9.62 -			if(!OpenDevice(AHINAME,0,(struct IORequest *)req,NULL))
    9.63 -			{
    9.64 -				D(bug("AHI available.\n"));
    9.65 -				ok=1;
    9.66 -				CloseDevice((struct IORequest *)req);
    9.67 -			}
    9.68 -			DeleteIORequest((struct IORequest *)req);
    9.69 -		}
    9.70 -		DeleteMsgPort(p);
    9.71 -	}
    9.72 -
    9.73 -	D(if(!ok) bug("AHI not available\n"));
    9.74 -	return ok;
    9.75 -}
    9.76 -
    9.77 -static void Audio_DeleteDevice(SDL_AudioDevice *device)
    9.78 -{
    9.79 -	SDL_free(device->hidden);
    9.80 -	SDL_free(device);
    9.81 -}
    9.82 -
    9.83 -static SDL_AudioDevice *Audio_CreateDevice(int devindex)
    9.84 -{
    9.85 -	SDL_AudioDevice *this;
    9.86 -
    9.87 -#ifndef NO_AMIGADEBUG
    9.88 -	D(bug("AHI created...\n"));
    9.89 -#endif
    9.90 -
    9.91 -	/* Initialize all variables that we clean on shutdown */
    9.92 -	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
    9.93 -	if ( this ) {
    9.94 -		SDL_memset(this, 0, (sizeof *this));
    9.95 -		this->hidden = (struct SDL_PrivateAudioData *)
    9.96 -				SDL_malloc((sizeof *this->hidden));
    9.97 -	}
    9.98 -	if ( (this == NULL) || (this->hidden == NULL) ) {
    9.99 -		SDL_OutOfMemory();
   9.100 -		if ( this ) {
   9.101 -			SDL_free(this);
   9.102 -		}
   9.103 -		return(0);
   9.104 -	}
   9.105 -	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   9.106 -
   9.107 -	/* Set the function pointers */
   9.108 -	this->OpenAudio = AHI_OpenAudio;
   9.109 -	this->WaitAudio = AHI_WaitAudio;
   9.110 -	this->PlayAudio = AHI_PlayAudio;
   9.111 -	this->GetAudioBuf = AHI_GetAudioBuf;
   9.112 -	this->CloseAudio = AHI_CloseAudio;
   9.113 -
   9.114 -	this->free = Audio_DeleteDevice;
   9.115 -
   9.116 -	return this;
   9.117 -}
   9.118 -
   9.119 -AudioBootStrap AHI_bootstrap = {
   9.120 -	"AHI", Audio_Available, Audio_CreateDevice
   9.121 -};
   9.122 -
   9.123 -
   9.124 -void static AHI_WaitAudio(_THIS)
   9.125 -{
   9.126 -	if(!CheckIO((struct IORequest *)audio_req[current_buffer]))
   9.127 -	{
   9.128 -		WaitIO((struct IORequest *)audio_req[current_buffer]);
   9.129 -//		AbortIO((struct IORequest *)audio_req[current_buffer]);
   9.130 -	}
   9.131 -}
   9.132 -
   9.133 -static void AHI_PlayAudio(_THIS)
   9.134 -{
   9.135 -	if(playing>1)
   9.136 -		WaitIO((struct IORequest *)audio_req[current_buffer]);
   9.137 -
   9.138 -	/* Write the audio data out */
   9.139 -	audio_req[current_buffer] -> ahir_Std. io_Message.mn_Node.ln_Pri = 60;
   9.140 -	audio_req[current_buffer] -> ahir_Std. io_Data                = mixbuf[current_buffer];
   9.141 -	audio_req[current_buffer] -> ahir_Std. io_Length              = this->hidden->size;
   9.142 -	audio_req[current_buffer] -> ahir_Std. io_Offset              = 0;
   9.143 -	audio_req[current_buffer] -> ahir_Std . io_Command            = CMD_WRITE;
   9.144 -	audio_req[current_buffer] -> ahir_Frequency                   = this->hidden->freq;
   9.145 -	audio_req[current_buffer] -> ahir_Volume                      = 0x10000;
   9.146 -	audio_req[current_buffer] -> ahir_Type                        = this->hidden->type;
   9.147 -	audio_req[current_buffer] -> ahir_Position                    = 0x8000;
   9.148 -	audio_req[current_buffer] -> ahir_Link                        = (playing>0 ? audio_req[current_buffer^1] : NULL);
   9.149 -
   9.150 -	SendIO((struct IORequest *)audio_req[current_buffer]);
   9.151 -	current_buffer^=1;
   9.152 -
   9.153 -	playing++;
   9.154 -}
   9.155 -
   9.156 -static Uint8 *AHI_GetAudioBuf(_THIS)
   9.157 -{
   9.158 -	return(mixbuf[current_buffer]);
   9.159 -}
   9.160 -
   9.161 -static void AHI_CloseAudio(_THIS)
   9.162 -{
   9.163 -	D(bug("Closing audio...\n"));
   9.164 -
   9.165 -	playing=0;
   9.166 -
   9.167 -	if(audio_req[0])
   9.168 -	{
   9.169 -		if(audio_req[1])
   9.170 -		{
   9.171 -			D(bug("Break req[1]...\n"));
   9.172 -
   9.173 -			AbortIO((struct IORequest *)audio_req[1]);
   9.174 -			WaitIO((struct IORequest *)audio_req[1]);
   9.175 -		}
   9.176 -
   9.177 -		D(bug("Break req[0]...\n"));
   9.178 -
   9.179 -		AbortIO((struct IORequest *)audio_req[0]);
   9.180 -		WaitIO((struct IORequest *)audio_req[0]);
   9.181 -
   9.182 -		if(audio_req[1])
   9.183 -		{
   9.184 -			D(bug("Break AGAIN req[1]...\n"));
   9.185 -			AbortIO((struct IORequest *)audio_req[1]);
   9.186 -			WaitIO((struct IORequest *)audio_req[1]);
   9.187 -		}
   9.188 -// Double abort to be sure to break the dbuffering process.
   9.189 -
   9.190 -		SDL_Delay(200);
   9.191 -
   9.192 -		D(bug("Reqs breaked, closing device...\n"));
   9.193 -		CloseDevice((struct IORequest *)audio_req[0]);
   9.194 -		D(bug("Device closed, freeing memory...\n"));
   9.195 -		myfree(audio_req[1]);
   9.196 -		D(bug("Memory freed, deleting IOReq...\n")); 
   9.197 -		DeleteIORequest((struct IORequest *)audio_req[0]);
   9.198 -		audio_req[0]=audio_req[1]=NULL;
   9.199 -	}
   9.200 -
   9.201 -	D(bug("Freeing mixbuf[0]...\n"));
   9.202 -	if ( mixbuf[0] != NULL ) {
   9.203 -		myfree(mixbuf[0]);
   9.204 -//		SDL_FreeAudioMem(mixbuf[0]);
   9.205 -		mixbuf[0] = NULL;
   9.206 -	}
   9.207 -
   9.208 -	D(bug("Freeing mixbuf[1]...\n"));
   9.209 -	if ( mixbuf[1] != NULL ) {
   9.210 -		myfree(mixbuf[1]);
   9.211 -//		SDL_FreeAudioMem(mixbuf[1]);
   9.212 -		mixbuf[1] = NULL;
   9.213 -	}
   9.214 -
   9.215 -	D(bug("Freeing audio_port...\n"));
   9.216 -
   9.217 -	if ( audio_port != NULL ) {
   9.218 -		DeleteMsgPort(audio_port);
   9.219 -		audio_port = NULL;
   9.220 -	}
   9.221 -	D(bug("...done!\n"));
   9.222 -}
   9.223 -
   9.224 -static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
   9.225 -{	
   9.226 -    Uint16 test_format = SDL_FirstAudioFormat(spec->format);
   9.227 -    int valid_datatype = 1;
   9.228 -
   9.229 -    D(bug("AHI opening...\n"));
   9.230 -
   9.231 -    /* Determine the audio parameters from the AudioSpec */
   9.232 -    while ((!valid_datatype) && (test_format)) {
   9.233 -        valid_datatype = 1;
   9.234 -        switch (test_format) {
   9.235 -            case AUDIO_S8:
   9.236 -                D(bug("AUDIO_S8...\n"));
   9.237 -                spec->format = AUDIO_S8;
   9.238 -                this->hidden->bytespersample = 1;
   9.239 -                if (spec->channels < 2)
   9.240 -                    this->hidden->type = AHIST_M8S;
   9.241 -                else
   9.242 -                    this->hidden->type = AHIST_S8S;
   9.243 -                break;
   9.244 -
   9.245 -            case AUDIO_S16MSB:
   9.246 -                D(bug("AUDIO_S16MSB...\n"));
   9.247 -                spec->format = AUDIO_S16MSB;
   9.248 -                this->hidden->bytespersample = 2;
   9.249 -                if (spec->channels < 2)
   9.250 -                    this->hidden->type = AHIST_M16S;
   9.251 -                else
   9.252 -                    this->hidden->type = AHIST_S16S;
   9.253 -                break;
   9.254 -
   9.255 -            default:
   9.256 -                valid_datatype = 0;
   9.257 -                test_format = SDL_NextAudioFormat();
   9.258 -                break;
   9.259 -        }
   9.260 -    }
   9.261 -
   9.262 -    if (!valid_datatype) { /* shouldn't happen, but just in case... */
   9.263 -        SDL_SetError("Unsupported audio format");
   9.264 -        return (-1);
   9.265 -    }
   9.266 -
   9.267 -    if (spec->channels > 2) {
   9.268 -        spec->channels = 2;  /* will convert at higher level. */
   9.269 -    }
   9.270 -
   9.271 -	D(bug("Before CalculateAudioSpec\n"));
   9.272 -	/* Update the fragment size as size in bytes */
   9.273 -	SDL_CalculateAudioSpec(spec);
   9.274 -
   9.275 -	D(bug("Before CreateMsgPort\n"));
   9.276 -
   9.277 -	if(!(audio_port=CreateMsgPort()))
   9.278 -	{
   9.279 -		SDL_SetError("Unable to create a MsgPort");
   9.280 -		return -1;
   9.281 -	}
   9.282 -
   9.283 -	D(bug("Before CreateIORequest\n"));
   9.284 -
   9.285 -	if(!(audio_req[0]=(struct AHIRequest *)CreateIORequest(audio_port,sizeof(struct AHIRequest))))
   9.286 -	{
   9.287 -		SDL_SetError("Unable to create an AHIRequest");
   9.288 -		DeleteMsgPort(audio_port);
   9.289 -		return -1;
   9.290 -	}
   9.291 -
   9.292 -	audio_req[0]->ahir_Version = 4;
   9.293 -
   9.294 -	if(OpenDevice(AHINAME,0,(struct IORequest *)audio_req[0],NULL))
   9.295 -	{
   9.296 -		SDL_SetError("Unable to open AHI device!\n");
   9.297 -		DeleteIORequest((struct IORequest *)audio_req[0]);
   9.298 -		DeleteMsgPort(audio_port);
   9.299 -		return -1;
   9.300 -	}
   9.301 -	
   9.302 -	D(bug("AFTER opendevice\n"));
   9.303 -
   9.304 -	/* Set output frequency and size */
   9.305 -	this->hidden->freq = spec->freq;
   9.306 -	this->hidden->size = spec->size;
   9.307 -
   9.308 -	D(bug("Before buffer allocation\n"));
   9.309 -
   9.310 -	/* Allocate mixing buffer */
   9.311 -	mixbuf[0] = (Uint8 *)mymalloc(spec->size);
   9.312 -	mixbuf[1] = (Uint8 *)mymalloc(spec->size);
   9.313 -
   9.314 -	D(bug("Before audio_req allocation\n"));
   9.315 -
   9.316 -	if(!(audio_req[1]=mymalloc(sizeof(struct AHIRequest))))
   9.317 -	{
   9.318 -		SDL_OutOfMemory();
   9.319 -		return(-1);
   9.320 -	}
   9.321 -	
   9.322 -	D(bug("Before audio_req memcpy\n"));
   9.323 -
   9.324 -	SDL_memcpy(audio_req[1],audio_req[0],sizeof(struct AHIRequest));
   9.325 -
   9.326 -	if ( mixbuf[0] == NULL || mixbuf[1] == NULL ) {
   9.327 -		SDL_OutOfMemory();
   9.328 -		return(-1);
   9.329 -	}
   9.330 -
   9.331 -	D(bug("Before mixbuf memset\n"));
   9.332 -
   9.333 -	SDL_memset(mixbuf[0], spec->silence, spec->size);
   9.334 -	SDL_memset(mixbuf[1], spec->silence, spec->size);
   9.335 -
   9.336 -	current_buffer=0;
   9.337 -	playing=0;
   9.338 -
   9.339 -	D(bug("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld channels:%ld\n",spec->freq,mixbuf[0],mixbuf[1],spec->size,this->hidden->bytespersample*8,spec->channels));
   9.340 -
   9.341 -	/* We're ready to rock and roll. :-) */
   9.342 -	return(0);
   9.343 -}
    10.1 --- a/src/audio/amigaos/SDL_ahiaudio.h	Sun Oct 29 03:44:25 2006 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,60 +0,0 @@
    10.4 -/*
    10.5 -    SDL - Simple DirectMedia Layer
    10.6 -    Copyright (C) 1997-2006 Sam Lantinga
    10.7 -
    10.8 -    This library is free software; you can redistribute it and/or
    10.9 -    modify it under the terms of the GNU Lesser General Public
   10.10 -    License as published by the Free Software Foundation; either
   10.11 -    version 2.1 of the License, or (at your option) any later version.
   10.12 -
   10.13 -    This library is distributed in the hope that it will be useful,
   10.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.16 -    Lesser General Public License for more details.
   10.17 -
   10.18 -    You should have received a copy of the GNU Lesser General Public
   10.19 -    License along with this library; if not, write to the Free Software
   10.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   10.21 -
   10.22 -    Sam Lantinga
   10.23 -    slouken@libsdl.org
   10.24 -*/
   10.25 -#include "SDL_config.h"
   10.26 -
   10.27 -#ifndef _SDL_ahiaudio_h
   10.28 -#define _SDL_ahiaudio_h
   10.29 -
   10.30 -#include <exec/exec.h>
   10.31 -#include <dos/dos.h>
   10.32 -#ifdef __SASC
   10.33 -#include <proto/exec.h>
   10.34 -#else
   10.35 -#include <inline/exec.h>
   10.36 -#endif
   10.37 -
   10.38 -#include <devices/ahi.h>
   10.39 -#include "mydebug.h"
   10.40 -
   10.41 -#include "../SDL_sysaudio.h"
   10.42 -
   10.43 -/* Hidden "this" pointer for the audio functions */
   10.44 -#define _THIS	SDL_AudioDevice *this
   10.45 -
   10.46 -struct SDL_PrivateAudioData {
   10.47 -	/* The handle for the audio device */
   10.48 -	struct AHIRequest *audio_req[2];
   10.49 -	struct MsgPort *audio_port;
   10.50 -	Sint32 freq,type,bytespersample,size;
   10.51 -	Uint8 *mixbuf[2];           /* The app mixing buffer */
   10.52 -	int current_buffer;
   10.53 -	Uint32 playing;
   10.54 -};
   10.55 -
   10.56 -/* Old variable names */
   10.57 -#define audio_port		(this->hidden->audio_port)
   10.58 -#define audio_req		(this->hidden->audio_req)
   10.59 -#define mixbuf			(this->hidden->mixbuf)
   10.60 -#define current_buffer		(this->hidden->current_buffer)
   10.61 -#define playing			(this->hidden->playing)
   10.62 -
   10.63 -#endif /* _SDL_ahiaudio_h */
    11.1 --- a/src/joystick/amigaos/SDL_sysjoystick.c	Sun Oct 29 03:44:25 2006 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,233 +0,0 @@
    11.4 -/*
    11.5 -    SDL - Simple DirectMedia Layer
    11.6 -    Copyright (C) 1997-2006 Sam Lantinga
    11.7 -
    11.8 -    This library is free software; you can redistribute it and/or
    11.9 -    modify it under the terms of the GNU Lesser General Public
   11.10 -    License as published by the Free Software Foundation; either
   11.11 -    version 2.1 of the License, or (at your option) any later version.
   11.12 -
   11.13 -    This library is distributed in the hope that it will be useful,
   11.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.16 -    Lesser General Public License for more details.
   11.17 -
   11.18 -    You should have received a copy of the GNU Lesser General Public
   11.19 -    License along with this library; if not, write to the Free Software
   11.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.21 -
   11.22 -    Sam Lantinga
   11.23 -    slouken@libsdl.org
   11.24 -*/
   11.25 -#include "SDL_config.h"
   11.26 -
   11.27 -#ifdef SDL_JOYSTICK_AMIGA
   11.28 -
   11.29 -/* This is the system specific header for the SDL joystick API */
   11.30 -
   11.31 -#include <libraries/lowlevel.h>
   11.32 -#if defined(__SASC) || defined(STORMC4_WOS)
   11.33 -#include <proto/exec.h>
   11.34 -#include <proto/lowlevel.h>
   11.35 -#include <proto/graphics.h>
   11.36 -#else
   11.37 -#include <inline/exec.h>
   11.38 -#include <inline/lowlevel.h>
   11.39 -#include <inline/graphics.h>
   11.40 -#endif
   11.41 -#include "mydebug.h"
   11.42 -
   11.43 -extern struct ExecBase *SysBase;
   11.44 -extern struct GfxBase *GfxBase;
   11.45 -
   11.46 -#include "SDL_joystick.h"
   11.47 -#include "../SDL_sysjoystick.h"
   11.48 -#include "../SDL_joystick_c.h"
   11.49 -
   11.50 -/* Function to scan the system for joysticks.
   11.51 - * This function should set SDL_numjoysticks to the number of available
   11.52 - * joysticks.  Joystick 0 should be the system default joystick.
   11.53 - * It should return 0, or -1 on an unrecoverable fatal error.
   11.54 - */
   11.55 -
   11.56 -
   11.57 -/* Amiga specific datas */
   11.58 -struct Library *LowLevelBase=NULL;
   11.59 -
   11.60 -ULONG joybut[]=
   11.61 -{
   11.62 -	JPF_BUTTON_RED,
   11.63 -	JPF_BUTTON_BLUE,
   11.64 -	JPF_BUTTON_PLAY,
   11.65 -	JPF_BUTTON_YELLOW,
   11.66 -	JPF_BUTTON_GREEN,
   11.67 -	JPF_BUTTON_FORWARD,
   11.68 -	JPF_BUTTON_REVERSE,
   11.69 -};
   11.70 -
   11.71 -struct joystick_hwdata
   11.72 -{
   11.73 -	ULONG joystate;
   11.74 -};
   11.75 -
   11.76 -int SDL_SYS_JoystickInit(void)
   11.77 -{
   11.78 -	if(!LowLevelBase)
   11.79 -	{
   11.80 -		if(LowLevelBase=OpenLibrary("lowlevel.library",37))
   11.81 -			return 2;
   11.82 -	}
   11.83 -	else
   11.84 -		return 2;
   11.85 -
   11.86 -	D(bug("%ld joysticks available.\n",SDL_numjoysticks));
   11.87 -
   11.88 -	return 0;
   11.89 -}
   11.90 -
   11.91 -/* Function to get the device-dependent name of a joystick */
   11.92 -const char *SDL_SYS_JoystickName(int index)
   11.93 -{
   11.94 -	if(index<2&&LowLevelBase)
   11.95 -	{
   11.96 -		switch(index)
   11.97 -		{
   11.98 -			case 0:
   11.99 -				return "Port 1 Amiga Joystick/Joypad";
  11.100 -			case 1:
  11.101 -				return "Port 2 Amiga Joystick/Joypad";
  11.102 -		}
  11.103 -	}
  11.104 -
  11.105 -	SDL_SetError("No joystick available with that index");
  11.106 -	return(NULL);
  11.107 -}
  11.108 -
  11.109 -/* Function to open a joystick for use.
  11.110 -   The joystick to open is specified by the index field of the joystick.
  11.111 -   This should fill the nbuttons and naxes fields of the joystick structure.
  11.112 -   It returns 0, or -1 if there is an error.
  11.113 - */
  11.114 -
  11.115 -int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
  11.116 -{
  11.117 -	ULONG temp,i;
  11.118 -	D(bug("Opening joystick %ld\n",joystick->index));
  11.119 -
  11.120 -	if(!(joystick->hwdata=SDL_malloc(sizeof(struct joystick_hwdata))))
  11.121 -		return -1;
  11.122 -
  11.123 -/* This loop is to check if the controller is a joypad */
  11.124 -
  11.125 -	for(i=0;i<20;i++)
  11.126 -	{
  11.127 -		temp=ReadJoyPort(joystick->index^1); // fix to invert amiga joyports
  11.128 -		WaitTOF();
  11.129 -	}
  11.130 -
  11.131 -	if((temp&JP_TYPE_MASK)==JP_TYPE_GAMECTLR)
  11.132 -		joystick->nbuttons=7;
  11.133 -	else
  11.134 -		joystick->nbuttons=3;
  11.135 -
  11.136 -	joystick->nhats=0;
  11.137 -	joystick->nballs=0;
  11.138 -	joystick->naxes=2;
  11.139 -	joystick->hwdata->joystate=0L;
  11.140 -
  11.141 -	return 0;
  11.142 -}
  11.143 -
  11.144 -/* Function to update the state of a joystick - called as a device poll.
  11.145 - * This function shouldn't update the joystick structure directly,
  11.146 - * but instead should call SDL_PrivateJoystick*() to deliver events
  11.147 - * and update joystick device state.
  11.148 - */
  11.149 -void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
  11.150 -{
  11.151 -	ULONG data;
  11.152 -	int i;
  11.153 -
  11.154 -	if(joystick->index<2)
  11.155 -	{
  11.156 -		data=ReadJoyPort(joystick->index);
  11.157 -
  11.158 -		if(data&JP_DIRECTION_MASK)
  11.159 -		{
  11.160 -			if(data&JPF_JOY_DOWN)
  11.161 -			{
  11.162 -				if(!(joystick->hwdata->joystate&JPF_JOY_DOWN))
  11.163 -					SDL_PrivateJoystickAxis(joystick,0,127);
  11.164 -			}
  11.165 -			else if(data&JPF_JOY_UP)
  11.166 -			{
  11.167 -				if(!(joystick->hwdata->joystate&JPF_JOY_UP))
  11.168 -					SDL_PrivateJoystickAxis(joystick,0,-127);
  11.169 -			}
  11.170 -			else if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN))
  11.171 -				SDL_PrivateJoystickAxis(joystick,0,0);
  11.172 -
  11.173 -			if(data&JPF_JOY_LEFT)
  11.174 -			{
  11.175 -				if(!(joystick->hwdata->joystate&JPF_JOY_LEFT))
  11.176 -					SDL_PrivateJoystickAxis(joystick,1,-127);
  11.177 -			}
  11.178 -			else if(data&JPF_JOY_RIGHT)
  11.179 -			{
  11.180 -				if(!(joystick->hwdata->joystate&JPF_JOY_RIGHT))
  11.181 -					SDL_PrivateJoystickAxis(joystick,1,127);
  11.182 -			}
  11.183 -			else if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT))
  11.184 -				SDL_PrivateJoystickAxis(joystick,1,0);
  11.185 -		}
  11.186 -		else if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT))
  11.187 -		{
  11.188 -				SDL_PrivateJoystickAxis(joystick,1,0);
  11.189 -		}
  11.190 -		else if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN))
  11.191 -		{
  11.192 -				SDL_PrivateJoystickAxis(joystick,0,0);
  11.193 -		}
  11.194 -
  11.195 -		for(i=0;i<joystick->nbuttons;i++)
  11.196 -		{
  11.197 -			if( (data&joybut[i]) )
  11.198 -			{
  11.199 -				if(i==1)
  11.200 -					data&=(~(joybut[2]));
  11.201 -
  11.202 -				if(!(joystick->hwdata->joystate&joybut[i]))
  11.203 -					SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED);
  11.204 -			}
  11.205 -			else if(joystick->hwdata->joystate&joybut[i])
  11.206 -				SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED);
  11.207 -		}
  11.208 -
  11.209 -		joystick->hwdata->joystate=data;
  11.210 -	}
  11.211 -
  11.212 -	return;
  11.213 -}
  11.214 -
  11.215 -/* Function to close a joystick after use */
  11.216 -void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
  11.217 -{
  11.218 -	if(joystick->hwdata)
  11.219 -		SDL_free(joystick->hwdata);
  11.220 -	return;
  11.221 -}
  11.222 -
  11.223 -/* Function to perform any system-specific joystick related cleanup */
  11.224 -
  11.225 -void SDL_SYS_JoystickQuit(void)
  11.226 -{
  11.227 -	if(LowLevelBase)
  11.228 -	{
  11.229 -		CloseLibrary(LowLevelBase);
  11.230 -		LowLevelBase=NULL;
  11.231 -		SDL_numjoysticks=0;
  11.232 -	}
  11.233 -	return;
  11.234 -}
  11.235 -
  11.236 -#endif /* SDL_JOYSTICK_AMIGA */
    12.1 --- a/src/thread/SDL_thread_c.h	Sun Oct 29 03:44:25 2006 +0000
    12.2 +++ b/src/thread/SDL_thread_c.h	Sun Oct 29 03:58:27 2006 +0000
    12.3 @@ -27,8 +27,6 @@
    12.4  /* Need the definitions of SYS_ThreadHandle */
    12.5  #if SDL_THREADS_DISABLED
    12.6  #include "generic/SDL_systhread_c.h"
    12.7 -#elif SDL_THREAD_AMIGA
    12.8 -#include "amigaos/SDL_systhread_c.h"
    12.9  #elif SDL_THREAD_BEOS
   12.10  #include "beos/SDL_systhread_c.h"
   12.11  #elif SDL_THREAD_DC
    13.1 --- a/src/thread/amigaos/SDL_syssem.c	Sun Oct 29 03:44:25 2006 +0000
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,148 +0,0 @@
    13.4 -/*
    13.5 -    SDL - Simple DirectMedia Layer
    13.6 -    Copyright (C) 1997-2006 Sam Lantinga
    13.7 -
    13.8 -    This library is free software; you can redistribute it and/or
    13.9 -    modify it under the terms of the GNU Lesser General Public
   13.10 -    License as published by the Free Software Foundation; either
   13.11 -    version 2.1 of the License, or (at your option) any later version.
   13.12 -
   13.13 -    This library is distributed in the hope that it will be useful,
   13.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.16 -    Lesser General Public License for more details.
   13.17 -
   13.18 -    You should have received a copy of the GNU Lesser General Public
   13.19 -    License along with this library; if not, write to the Free Software
   13.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.21 -
   13.22 -    Sam Lantinga
   13.23 -    slouken@libsdl.org
   13.24 -*/
   13.25 -#include "SDL_config.h"
   13.26 -
   13.27 -/* An implementation of semaphores using mutexes and condition variables */
   13.28 -
   13.29 -#include "SDL_thread.h"
   13.30 -#include "SDL_systhread_c.h"
   13.31 -
   13.32 -
   13.33 -struct SDL_semaphore
   13.34 -{
   13.35 -	struct SignalSemaphore Sem;
   13.36 -};
   13.37 -
   13.38 -#undef D
   13.39 -
   13.40 -#define D(x)
   13.41 -
   13.42 -SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
   13.43 -{
   13.44 -	SDL_sem *sem;
   13.45 -
   13.46 -	sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
   13.47 -
   13.48 -	if ( ! sem ) {
   13.49 -		SDL_OutOfMemory();
   13.50 -		return(0);
   13.51 -	}
   13.52 -
   13.53 -	D(bug("Creating semaphore %lx...\n",sem));
   13.54 -
   13.55 -	SDL_memset(sem,0,sizeof(*sem));
   13.56 -
   13.57 -	InitSemaphore(&sem->Sem);
   13.58 -
   13.59 -	return(sem);
   13.60 -}
   13.61 -
   13.62 -void SDL_DestroySemaphore(SDL_sem *sem)
   13.63 -{
   13.64 -	D(bug("Destroying semaphore %lx...\n",sem));
   13.65 -
   13.66 -	if ( sem ) {
   13.67 -// Condizioni per liberare i task in attesa?
   13.68 -		SDL_free(sem);
   13.69 -	}
   13.70 -}
   13.71 -
   13.72 -int SDL_SemTryWait(SDL_sem *sem)
   13.73 -{
   13.74 -	if ( ! sem ) {
   13.75 -		SDL_SetError("Passed a NULL semaphore");
   13.76 -		return -1;
   13.77 -	}
   13.78 -
   13.79 -	D(bug("TryWait semaphore...%lx\n",sem));
   13.80 -
   13.81 -	ObtainSemaphore(&sem->Sem);
   13.82 -//	ReleaseSemaphore(&sem->Sem);
   13.83 -
   13.84 -	return 1;
   13.85 -}
   13.86 -
   13.87 -int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
   13.88 -{
   13.89 -	int retval;
   13.90 -
   13.91 -
   13.92 -	if ( ! sem ) {
   13.93 -		SDL_SetError("Passed a NULL semaphore");
   13.94 -		return -1;
   13.95 -	}
   13.96 -
   13.97 -	D(bug("WaitTimeout (%ld) semaphore...%lx\n",timeout,sem));
   13.98 -
   13.99 -	/* A timeout of 0 is an easy case */
  13.100 -	if ( timeout == 0 ) {
  13.101 -		ObtainSemaphore(&sem->Sem);
  13.102 -		return 1;
  13.103 -	}
  13.104 -	if(!(retval=AttemptSemaphore(&sem->Sem)))
  13.105 -	{
  13.106 -		SDL_Delay(timeout);
  13.107 -		retval=AttemptSemaphore(&sem->Sem);
  13.108 -	}
  13.109 -
  13.110 -	if(retval==TRUE)
  13.111 -	{
  13.112 -//		ReleaseSemaphore(&sem->Sem);
  13.113 -		retval=1;
  13.114 -	}
  13.115 -
  13.116 -	return retval;
  13.117 -}
  13.118 -
  13.119 -int SDL_SemWait(SDL_sem *sem)
  13.120 -{
  13.121 -	ObtainSemaphore(&sem->Sem);
  13.122 -	return 0;
  13.123 -}
  13.124 -
  13.125 -Uint32 SDL_SemValue(SDL_sem *sem)
  13.126 -{
  13.127 -	Uint32 value;
  13.128 -
  13.129 -	value = 0;
  13.130 -	if ( sem ) {
  13.131 -		#ifdef STORMC4_WOS
  13.132 -		value = sem->Sem.ssppc_SS.ss_NestCount;
  13.133 -		#else
  13.134 -		value = sem->Sem.ss_NestCount;
  13.135 -		#endif
  13.136 -	}
  13.137 -	return value;
  13.138 -}
  13.139 -
  13.140 -int SDL_SemPost(SDL_sem *sem)
  13.141 -{
  13.142 -	if ( ! sem ) {
  13.143 -		SDL_SetError("Passed a NULL semaphore");
  13.144 -		return -1;
  13.145 -	}
  13.146 -	D(bug("SemPost semaphore...%lx\n",sem));
  13.147 -
  13.148 -	ReleaseSemaphore(&sem->Sem);
  13.149 -	return 0;
  13.150 -}
  13.151 -
    14.1 --- a/src/thread/amigaos/SDL_systhread.c	Sun Oct 29 03:44:25 2006 +0000
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,151 +0,0 @@
    14.4 -/*
    14.5 -    SDL - Simple DirectMedia Layer
    14.6 -    Copyright (C) 1997-2006 Sam Lantinga
    14.7 -
    14.8 -    This library is free software; you can redistribute it and/or
    14.9 -    modify it under the terms of the GNU Lesser General Public
   14.10 -    License as published by the Free Software Foundation; either
   14.11 -    version 2.1 of the License, or (at your option) any later version.
   14.12 -
   14.13 -    This library is distributed in the hope that it will be useful,
   14.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14.16 -    Lesser General Public License for more details.
   14.17 -
   14.18 -    You should have received a copy of the GNU Lesser General Public
   14.19 -    License along with this library; if not, write to the Free Software
   14.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   14.21 -
   14.22 -    Sam Lantinga
   14.23 -    slouken@libsdl.org
   14.24 -*/
   14.25 -#include "SDL_config.h"
   14.26 -
   14.27 -/* BeOS thread management routines for SDL */
   14.28 -
   14.29 -#include "SDL_mutex.h"
   14.30 -#include "SDL_thread.h"
   14.31 -#include "../SDL_thread_c.h"
   14.32 -#include "../SDL_systhread.h"
   14.33 -#include "mydebug.h"
   14.34 -
   14.35 -typedef struct {
   14.36 -	int (*func)(void *);
   14.37 -	void *data;
   14.38 -	SDL_Thread *info;
   14.39 -	struct Task *wait;
   14.40 -} thread_args;
   14.41 -
   14.42 -#ifndef MORPHOS
   14.43 -
   14.44 -#if defined(__SASC) && !defined(__PPC__) 
   14.45 -__saveds __asm Uint32 RunThread(register __a0 char *args )
   14.46 -#elif defined(__PPC__)
   14.47 -Uint32 RunThread(char *args)
   14.48 -#else
   14.49 -Uint32 __saveds RunThread(char *args __asm("a0") )
   14.50 -#endif
   14.51 -{
   14.52 -	#ifdef STORMC4_WOS
   14.53 -	thread_args *data=(thread_args *)args;
   14.54 -	#else
   14.55 -	thread_args *data=(thread_args *)atol(args);
   14.56 -	#endif
   14.57 -
   14.58 -	struct Task *Father;
   14.59 -
   14.60 -	D(bug("Received data: %lx\n",data));
   14.61 -	Father=data->wait;
   14.62 -
   14.63 -	SDL_RunThread(data);
   14.64 -
   14.65 -	Signal(Father,SIGBREAKF_CTRL_F);
   14.66 -	D(bug("Thread with data %lx ended\n",data));
   14.67 -	return(0);
   14.68 -}
   14.69 -
   14.70 -#else
   14.71 -
   14.72 -#include <emul/emulinterface.h>
   14.73 -
   14.74 -Uint32 RunTheThread(void)
   14.75 -{
   14.76 -	thread_args *data=(thread_args *)atol((char *)REG_A0);
   14.77 -	struct Task *Father;
   14.78 -
   14.79 -	D(bug("Received data: %lx\n",data));
   14.80 -	Father=data->wait;
   14.81 -
   14.82 -	SDL_RunThread(data);
   14.83 -
   14.84 -	Signal(Father,SIGBREAKF_CTRL_F);
   14.85 -	D(bug("Thread with data %lx ended\n",data));
   14.86 -	return(0);
   14.87 -}
   14.88 -
   14.89 -struct EmulLibEntry RunThreadStruct=
   14.90 -{
   14.91 -	TRAP_LIB,
   14.92 -	0,
   14.93 -	(ULONG)RunTheThread
   14.94 -};
   14.95 -
   14.96 -void *RunThread=&RunThreadStruct;
   14.97 -#endif
   14.98 -
   14.99 -
  14.100 -int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
  14.101 -{
  14.102 -	/* Create the thread and go! */
  14.103 -	char buffer[20];
  14.104 -
  14.105 -	D(bug("Sending %lx to the new thread...\n",args));
  14.106 -
  14.107 -	if(args)
  14.108 -		SDL_snprintf(buffer, SDL_arraysize(buffer),"%ld",args);
  14.109 -
  14.110 -	#ifdef STORMC4_WOS
  14.111 -	thread->handle=CreateTaskPPCTags(TASKATTR_CODE,	RunThread,
  14.112 -					TASKATTR_NAME,	"SDL subtask",
  14.113 -					TASKATTR_STACKSIZE, 100000,
  14.114 -					(args ? TASKATTR_R3 : TAG_IGNORE), args,
  14.115 -					TASKATTR_INHERITR2, TRUE,
  14.116 -					TAG_DONE);
  14.117 -	#else
  14.118 -	thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(),
  14.119 -					NP_Name,(ULONG)"SDL subtask",
  14.120 -					NP_CloseOutput, FALSE,
  14.121 -					NP_StackSize,20000,
  14.122 -					NP_Entry,(ULONG)RunThread,
  14.123 -					args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer,
  14.124 -					TAG_DONE);
  14.125 -	#endif
  14.126 -
  14.127 -	if(!thread->handle)
  14.128 -	{
  14.129 -		SDL_SetError("Not enough resources to create thread");
  14.130 -		return(-1);
  14.131 -	}
  14.132 -
  14.133 -	return(0);
  14.134 -}
  14.135 -
  14.136 -void SDL_SYS_SetupThread(void)
  14.137 -{
  14.138 -}
  14.139 -
  14.140 -Uint32 SDL_ThreadID(void)
  14.141 -{
  14.142 -	return((Uint32)FindTask(NULL));
  14.143 -}
  14.144 -
  14.145 -void SDL_SYS_WaitThread(SDL_Thread *thread)
  14.146 -{
  14.147 -	SetSignal(0L,SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C);
  14.148 -	Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C);
  14.149 -}
  14.150 -
  14.151 -void SDL_SYS_KillThread(SDL_Thread *thread)
  14.152 -{
  14.153 -	Signal((struct Task *)thread->handle,SIGBREAKF_CTRL_C);
  14.154 -}
    15.1 --- a/src/thread/amigaos/SDL_systhread_c.h	Sun Oct 29 03:44:25 2006 +0000
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,61 +0,0 @@
    15.4 -/*
    15.5 -    SDL - Simple DirectMedia Layer
    15.6 -    Copyright (C) 1997-2006 Sam Lantinga
    15.7 -
    15.8 -    This library is free software; you can redistribute it and/or
    15.9 -    modify it under the terms of the GNU Lesser General Public
   15.10 -    License as published by the Free Software Foundation; either
   15.11 -    version 2.1 of the License, or (at your option) any later version.
   15.12 -
   15.13 -    This library is distributed in the hope that it will be useful,
   15.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15.16 -    Lesser General Public License for more details.
   15.17 -
   15.18 -    You should have received a copy of the GNU Lesser General Public
   15.19 -    License along with this library; if not, write to the Free Software
   15.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   15.21 -
   15.22 -    Sam Lantinga
   15.23 -    slouken@libsdl.org
   15.24 -*/
   15.25 -#include "SDL_config.h"
   15.26 -
   15.27 -#include <exec/exec.h>
   15.28 -#include <dos/dos.h>
   15.29 -#include <dos/dostags.h>
   15.30 -#if defined (__SASC) || defined(STORMC4_WOS)
   15.31 -#include <proto/dos.h>
   15.32 -#include <proto/exec.h>
   15.33 -#else
   15.34 -#include <inline/dos.h>
   15.35 -#include <inline/exec.h>
   15.36 -#endif
   15.37 -
   15.38 -#include "mydebug.h"
   15.39 -
   15.40 -extern struct ExecBase *SysBase;
   15.41 -extern struct DosLibrary *DOSBase;
   15.42 -
   15.43 -#ifdef STORMC4_WOS
   15.44 -#include <proto/powerpc.h>
   15.45 -
   15.46 -/* use powerpc.library functions instead og exec */
   15.47 -#define SYS_ThreadHandle struct TaskPPC *
   15.48 -#define Signal SignalPPC
   15.49 -#define Wait WaitPPC
   15.50 -#define Task TaskPPC
   15.51 -#define FindTask FindTaskPPC
   15.52 -#define SetSignal SetSignalPPC
   15.53 -
   15.54 -#define InitSemaphore InitSemaphorePPC
   15.55 -#define ObtainSemaphore ObtainSemaphorePPC
   15.56 -#define AttemptSemaphore AttemptSemaphorePPC
   15.57 -#define ReleaseSemaphore ReleaseSemaphorePPC
   15.58 -#define SignalSemaphore SignalSemaphorePPC
   15.59 -
   15.60 -#else
   15.61 -
   15.62 -#define SYS_ThreadHandle struct Task *
   15.63 -#endif /*STORMC4_WOS*/
   15.64 -
    16.1 --- a/src/thread/amigaos/SDL_thread.c	Sun Oct 29 03:44:25 2006 +0000
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,278 +0,0 @@
    16.4 -/*
    16.5 -    SDL - Simple DirectMedia Layer
    16.6 -    Copyright (C) 1997-2006 Sam Lantinga
    16.7 -
    16.8 -    This library is free software; you can redistribute it and/or
    16.9 -    modify it under the terms of the GNU Lesser General Public
   16.10 -    License as published by the Free Software Foundation; either
   16.11 -    version 2.1 of the License, or (at your option) any later version.
   16.12 -
   16.13 -    This library is distributed in the hope that it will be useful,
   16.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.16 -    Lesser General Public License for more details.
   16.17 -
   16.18 -    You should have received a copy of the GNU Lesser General Public
   16.19 -    License along with this library; if not, write to the Free Software
   16.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   16.21 -
   16.22 -    Sam Lantinga
   16.23 -    slouken@libsdl.org
   16.24 -*/
   16.25 -#include "SDL_config.h"
   16.26 -
   16.27 -/* System independent thread management routines for SDL */
   16.28 -
   16.29 -#include "SDL_mutex.h"
   16.30 -#include "SDL_thread.h"
   16.31 -#include "../SDL_thread_c.h"
   16.32 -#include "../SDL_systhread.h"
   16.33 -
   16.34 -#define ARRAY_CHUNKSIZE	32
   16.35 -/* The array of threads currently active in the application
   16.36 -   (except the main thread)
   16.37 -   The manipulation of an array here is safer than using a linked list.
   16.38 -*/
   16.39 -static int SDL_maxthreads = 0;
   16.40 -static int SDL_numthreads = 0;
   16.41 -static SDL_Thread **SDL_Threads = NULL;
   16.42 -static struct SignalSemaphore thread_lock;
   16.43 -int thread_lock_created = 0;
   16.44 -
   16.45 -int SDL_ThreadsInit(void)
   16.46 -{
   16.47 -	InitSemaphore(&thread_lock);
   16.48 -	thread_lock_created=1;
   16.49 -	return 0;
   16.50 -}
   16.51 -
   16.52 -/* This should never be called...
   16.53 -   If this is called by SDL_Quit(), we don't know whether or not we should
   16.54 -   clean up threads here.  If any threads are still running after this call,
   16.55 -   they will no longer have access to any per-thread data.
   16.56 - */
   16.57 -void SDL_ThreadsQuit()
   16.58 -{
   16.59 -	thread_lock_created=0;
   16.60 -}
   16.61 -
   16.62 -/* Routines for manipulating the thread list */
   16.63 -static void SDL_AddThread(SDL_Thread *thread)
   16.64 -{
   16.65 -	SDL_Thread **threads;
   16.66 -
   16.67 -	/* WARNING:
   16.68 -	   If the very first threads are created simultaneously, then
   16.69 -	   there could be a race condition causing memory corruption.
   16.70 -	   In practice, this isn't a problem because by definition there
   16.71 -	   is only one thread running the first time this is called.
   16.72 -	*/
   16.73 -	if ( !thread_lock_created ) {
   16.74 -		if ( SDL_ThreadsInit() < 0 ) {
   16.75 -			return;
   16.76 -		}
   16.77 -	}
   16.78 -	ObtainSemaphore(&thread_lock);
   16.79 -
   16.80 -	/* Expand the list of threads, if necessary */
   16.81 -#ifdef DEBUG_THREADS
   16.82 -	printf("Adding thread (%d already - %d max)\n",
   16.83 -			SDL_numthreads, SDL_maxthreads);
   16.84 -#endif
   16.85 -	if ( SDL_numthreads == SDL_maxthreads ) {
   16.86 -		threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
   16.87 -		                              (sizeof *threads));
   16.88 -		if ( threads == NULL ) {
   16.89 -			SDL_OutOfMemory();
   16.90 -			goto done;
   16.91 -		}
   16.92 -		SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
   16.93 -		SDL_maxthreads += ARRAY_CHUNKSIZE;
   16.94 -		if ( SDL_Threads ) {
   16.95 -			SDL_free(SDL_Threads);
   16.96 -		}
   16.97 -		SDL_Threads = threads;
   16.98 -	}
   16.99 -	SDL_Threads[SDL_numthreads++] = thread;
  16.100 -done:
  16.101 -	ReleaseSemaphore(&thread_lock);
  16.102 -}
  16.103 -
  16.104 -static void SDL_DelThread(SDL_Thread *thread)
  16.105 -{
  16.106 -	int i;
  16.107 -
  16.108 -	if ( thread_lock_created ) {
  16.109 -		ObtainSemaphore(&thread_lock);
  16.110 -		for ( i=0; i<SDL_numthreads; ++i ) {
  16.111 -			if ( thread == SDL_Threads[i] ) {
  16.112 -				break;
  16.113 -			}
  16.114 -		}
  16.115 -		if ( i < SDL_numthreads ) {
  16.116 -			--SDL_numthreads;
  16.117 -			while ( i < SDL_numthreads ) {
  16.118 -				SDL_Threads[i] = SDL_Threads[i+1];
  16.119 -				++i;
  16.120 -			}
  16.121 -#ifdef DEBUG_THREADS
  16.122 -			printf("Deleting thread (%d left - %d max)\n",
  16.123 -					SDL_numthreads, SDL_maxthreads);
  16.124 -#endif
  16.125 -		}
  16.126 -		ReleaseSemaphore(&thread_lock);
  16.127 -	}
  16.128 -}
  16.129 -
  16.130 -/* The default (non-thread-safe) global error variable */
  16.131 -static SDL_error SDL_global_error;
  16.132 -
  16.133 -/* Routine to get the thread-specific error variable */
  16.134 -SDL_error *SDL_GetErrBuf(void)
  16.135 -{
  16.136 -	SDL_error *errbuf;
  16.137 -
  16.138 -	errbuf = &SDL_global_error;
  16.139 -	if ( SDL_Threads ) {
  16.140 -		int i;
  16.141 -		Uint32 this_thread;
  16.142 -
  16.143 -		this_thread = SDL_ThreadID();
  16.144 -		ObtainSemaphore(&thread_lock);
  16.145 -		for ( i=0; i<SDL_numthreads; ++i ) {
  16.146 -			if ( this_thread == SDL_Threads[i]->threadid ) {
  16.147 -				errbuf = &SDL_Threads[i]->errbuf;
  16.148 -				break;
  16.149 -			}
  16.150 -		}
  16.151 -		ReleaseSemaphore(&thread_lock);
  16.152 -	}
  16.153 -	return(errbuf);
  16.154 -}
  16.155 -
  16.156 -
  16.157 -/* Arguments and callback to setup and run the user thread function */
  16.158 -typedef struct {
  16.159 -	int (*func)(void *);
  16.160 -	void *data;
  16.161 -	SDL_Thread *info;
  16.162 -	struct Task *wait;
  16.163 -} thread_args;
  16.164 -
  16.165 -void SDL_RunThread(void *data)
  16.166 -{
  16.167 -	thread_args *args;
  16.168 -	int (*userfunc)(void *);
  16.169 -	void *userdata;
  16.170 -	int *statusloc;
  16.171 -
  16.172 -	/* Perform any system-dependent setup
  16.173 -	   - this function cannot fail, and cannot use SDL_SetError()
  16.174 -	 */
  16.175 -	SDL_SYS_SetupThread();
  16.176 -
  16.177 -	/* Get the thread id */
  16.178 -	args = (thread_args *)data;
  16.179 -	args->info->threadid = SDL_ThreadID();
  16.180 -
  16.181 -	/* Figure out what function to run */
  16.182 -	userfunc = args->func;
  16.183 -	userdata = args->data;
  16.184 -	statusloc = &args->info->status;
  16.185 -
  16.186 -	/* Wake up the parent thread */
  16.187 -	Signal(args->wait,SIGBREAKF_CTRL_E);
  16.188 -
  16.189 -	/* Run the function */
  16.190 -	*statusloc = userfunc(userdata);
  16.191 -}
  16.192 -
  16.193 -SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
  16.194 -{
  16.195 -	SDL_Thread *thread;
  16.196 -	thread_args *args;
  16.197 -	int ret;
  16.198 -
  16.199 -	/* Allocate memory for the thread info structure */
  16.200 -	thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
  16.201 -	if ( thread == NULL ) {
  16.202 -		SDL_OutOfMemory();
  16.203 -		return(NULL);
  16.204 -	}
  16.205 -	SDL_memset(thread, 0, (sizeof *thread));
  16.206 -	thread->status = -1;
  16.207 -
  16.208 -	/* Set up the arguments for the thread */
  16.209 -	args = (thread_args *)SDL_malloc(sizeof(*args));
  16.210 -	if ( args == NULL ) {
  16.211 -		SDL_OutOfMemory();
  16.212 -		SDL_free(thread);
  16.213 -		return(NULL);
  16.214 -	}
  16.215 -	args->func = fn;
  16.216 -	args->data = data;
  16.217 -	args->info = thread;
  16.218 -	args->wait = FindTask(NULL);
  16.219 -	if ( args->wait == NULL ) {
  16.220 -		SDL_free(thread);
  16.221 -		SDL_free(args);
  16.222 -		SDL_OutOfMemory();
  16.223 -		return(NULL);
  16.224 -	}
  16.225 -
  16.226 -	/* Add the thread to the list of available threads */
  16.227 -	SDL_AddThread(thread);
  16.228 -
  16.229 -	D(bug("Starting thread...\n"));
  16.230 -
  16.231 -	/* Create the thread and go! */
  16.232 -	ret = SDL_SYS_CreateThread(thread, args);
  16.233 -	if ( ret >= 0 ) {
  16.234 -		D(bug("Waiting for thread CTRL_E...\n"));
  16.235 -		/* Wait for the thread function to use arguments */
  16.236 -		Wait(SIGBREAKF_CTRL_E);
  16.237 -		D(bug("  Arrived."));
  16.238 -	} else {
  16.239 -		/* Oops, failed.  Gotta free everything */
  16.240 -		SDL_DelThread(thread);
  16.241 -		SDL_free(thread);
  16.242 -		thread = NULL;
  16.243 -	}
  16.244 -	SDL_free(args);
  16.245 -
  16.246 -	/* Everything is running now */
  16.247 -	return(thread);
  16.248 -}
  16.249 -
  16.250 -void SDL_WaitThread(SDL_Thread *thread, int *status)
  16.251 -{
  16.252 -	if ( thread ) {
  16.253 -		SDL_SYS_WaitThread(thread);
  16.254 -		if ( status ) {
  16.255 -			*status = thread->status;
  16.256 -		}
  16.257 -		SDL_DelThread(thread);
  16.258 -		SDL_free(thread);
  16.259 -	}
  16.260 -}
  16.261 -
  16.262 -Uint32 SDL_GetThreadID(SDL_Thread *thread)
  16.263 -{
  16.264 -	Uint32 id;
  16.265 -
  16.266 -	if ( thread ) {
  16.267 -		id = thread->threadid;
  16.268 -	} else {
  16.269 -		id = SDL_ThreadID();
  16.270 -	}
  16.271 -	return(id);
  16.272 -}
  16.273 -
  16.274 -void SDL_KillThread(SDL_Thread *thread)
  16.275 -{
  16.276 -	if ( thread ) {
  16.277 -		SDL_SYS_KillThread(thread);
  16.278 -		SDL_WaitThread(thread, NULL);
  16.279 -	}
  16.280 -}
  16.281 -
    17.1 --- a/src/timer/amigaos/SDL_systimer.c	Sun Oct 29 03:44:25 2006 +0000
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,267 +0,0 @@
    17.4 -/*
    17.5 -    SDL - Simple DirectMedia Layer
    17.6 -    Copyright (C) 1997-2006 Sam Lantinga
    17.7 -
    17.8 -    This library is free software; you can redistribute it and/or
    17.9 -    modify it under the terms of the GNU Lesser General Public
   17.10 -    License as published by the Free Software Foundation; either
   17.11 -    version 2.1 of the License, or (at your option) any later version.
   17.12 -
   17.13 -    This library is distributed in the hope that it will be useful,
   17.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.16 -    Lesser General Public License for more details.
   17.17 -
   17.18 -    You should have received a copy of the GNU Lesser General Public
   17.19 -    License along with this library; if not, write to the Free Software
   17.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   17.21 -
   17.22 -    Sam Lantinga
   17.23 -    slouken@libsdl.org
   17.24 -*/
   17.25 -#include "SDL_config.h"
   17.26 -
   17.27 -#ifdef SDL_TIMER_AMIGA
   17.28 -
   17.29 -#include <stdio.h>
   17.30 -#include <time.h>
   17.31 -#include <signal.h>
   17.32 -#include <unistd.h>
   17.33 -#include <string.h>
   17.34 -#include <errno.h>
   17.35 -#include <exec/types.h>
   17.36 -#ifdef __SASC
   17.37 -#include <proto/dos.h>
   17.38 -#include <clib/graphics_protos.h>
   17.39 -#include <pragmas/graphics.h>
   17.40 -#include <clib/exec_protos.h>
   17.41 -#include <pragmas/exec.h>
   17.42 -#elif defined(STORMC4_WOS)
   17.43 -#include <proto/dos.h>
   17.44 -#include <proto/exec.h>
   17.45 -#include <proto/graphics.h>
   17.46 -#else
   17.47 -#include <inline/dos.h>
   17.48 -#include <inline/exec.h>
   17.49 -#include <inline/graphics.h>
   17.50 -#endif
   17.51 -#include "mydebug.h"
   17.52 -
   17.53 -extern struct DosLibrary *DOSBase;
   17.54 -extern struct ExecBase *SysBase;
   17.55 -static struct GfxBase *GfxBase;
   17.56 -
   17.57 -#include "SDL_timer.h"
   17.58 -#include "../SDL_timer_c.h"
   17.59 -
   17.60 -/* The first ticks value of the application */
   17.61 -
   17.62 -#if !defined(__PPC__) || defined(STORMC4_WOS) || defined(MORPHOS)
   17.63 -static clock_t start;
   17.64 -
   17.65 -void SDL_StartTicks(void)
   17.66 -{
   17.67 -	/* Set first ticks value */
   17.68 -	start=clock();
   17.69 -}
   17.70 -
   17.71 -Uint32 SDL_GetTicks (void)
   17.72 -{
   17.73 -	clock_t ticks;
   17.74 -
   17.75 -	ticks=clock()-start;
   17.76 -
   17.77 -#ifdef __SASC
   17.78 -// CLOCKS_PER_SEC == 1000 !
   17.79 -
   17.80 -	return(ticks);
   17.81 -#else
   17.82 -// CLOCKS_PER_SEC != 1000 !
   17.83 -
   17.84 -	return ticks*(1000/CLOCKS_PER_SEC);
   17.85 -#endif
   17.86 -}
   17.87 -
   17.88 -void SDL_Delay (Uint32 ms)
   17.89 -{
   17.90 -// Do a busy wait if time is less than 50ms
   17.91 -
   17.92 -	if(ms<50)
   17.93 -	{
   17.94 -		clock_t to_wait=clock();
   17.95 -
   17.96 -#ifndef __SASC
   17.97 -		ms*=(CLOCKS_PER_SEC/1000);
   17.98 -#endif
   17.99 -		to_wait+=ms;
  17.100 -
  17.101 -		while(clock()<to_wait);
  17.102 -	}
  17.103 -	else
  17.104 -	{
  17.105 -		Delay(ms/20);
  17.106 -	}
  17.107 -}
  17.108 -
  17.109 -#else
  17.110 -
  17.111 -ULONG MY_CLOCKS_PER_SEC;
  17.112 -
  17.113 -void PPC_TimerInit(void);
  17.114 -APTR MyTimer;
  17.115 -
  17.116 -ULONG start[2];
  17.117 -
  17.118 -void SDL_StartTicks(void)
  17.119 -{
  17.120 -	/* Set first ticks value */
  17.121 -	if(!MyTimer)
  17.122 -		PPC_TimerInit();
  17.123 -
  17.124 -	PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,start);
  17.125 -	start[1]>>=10;
  17.126 -	start[1]|=((result[0]&0x3ff)<<22);
  17.127 -	start[0]>>=10;
  17.128 -}
  17.129 -
  17.130 -Uint32 SDL_GetTicks (void)
  17.131 -{
  17.132 -	ULONG result[2];
  17.133 -	PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result);
  17.134 -
  17.135 -//	PPCAsr64p(result,10);
  17.136 -// Non va, la emulo:
  17.137 -
  17.138 -	result[1]>>=10;
  17.139 -	result[1]|=((result[0]&0x3ff)<<22);
  17.140 -
  17.141 -// Non mi interessa piu' result[0]
  17.142 -
  17.143 -	return result[1]*1000/MY_CLOCKS_PER_SEC;
  17.144 -}
  17.145 -
  17.146 -void SDL_Delay (Uint32 ms)
  17.147 -{
  17.148 -// Do a busy wait if time is less than 50ms
  17.149 -
  17.150 -	if(ms<50)
  17.151 -	{
  17.152 -		ULONG to_wait[2],actual[2];
  17.153 -		PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result);
  17.154 -		actual[1]=0;
  17.155 -		to_wait[1]+=ms*1000/MY_CLOCKS_PER_SEC;
  17.156 -
  17.157 -		while(actual[1]<to_wait[1])
  17.158 -		{
  17.159 -			PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,actual);
  17.160 -		}
  17.161 -	}
  17.162 -	else
  17.163 -	{
  17.164 -		Delay(ms/50);
  17.165 -	}
  17.166 -}
  17.167 -
  17.168 -void PPC_TimerInit(void)
  17.169 -{
  17.170 -	struct TagItem tags[]=
  17.171 -		{
  17.172 -			PPCTIMERTAG_CPU,TRUE,
  17.173 -			TAG_DONE,0
  17.174 -		};
  17.175 -
  17.176 -
  17.177 -	if(MyTimer=PPCCreateTimerObject(tags))
  17.178 -	{
  17.179 -		ULONG result[2];
  17.180 -
  17.181 -		PPCGetTimerObject(MyTimer,PPCTIMERTAG_TICKSPERSEC,result);
  17.182 -		D(bug("Timer inizializzato, TPS: %lu - %lu\n",result[0],result[1]));
  17.183 -//		PPCAsr64p(result,10);
  17.184 -		result[1]>>=10;
  17.185 -		result[1]|=((result[0]&0x3ff)<<22);
  17.186 -		result[0]>>=10;
  17.187 -
  17.188 -		D(bug("Shiftato TPS: %lu - %lu\n",result[0],result[1]));
  17.189 -		MY_CLOCKS_PER_SEC=result[1];
  17.190 -
  17.191 -		PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result);
  17.192 -
  17.193 -		D(bug("Current ticks: %lu - %lu\n",result[0],result[1]));
  17.194 -		result[1]>>=10;
  17.195 -		result[1]|=((result[0]&0x3ff)<<22);
  17.196 -		result[0]>>=10;
  17.197 -//		PPCAsr64p(result,10);
  17.198 -		D(bug("Shiftato: %lu - %lu\n",result[0],result[1]));
  17.199 -	}
  17.200 -	else
  17.201 -	{
  17.202 -		D(bug("Errore nell'inizializzazione del timer!\n"));
  17.203 -	}
  17.204 -}
  17.205 -
  17.206 -#endif
  17.207 -
  17.208 -#include "SDL_thread.h"
  17.209 -
  17.210 -/* Data to handle a single periodic alarm */
  17.211 -static int timer_alive = 0;
  17.212 -static SDL_Thread *timer_thread = NULL;
  17.213 -
  17.214 -static int RunTimer(void *unused)
  17.215 -{
  17.216 -	D(bug("SYSTimer: Entering RunTimer loop..."));
  17.217 -
  17.218 -	if(GfxBase==NULL)
  17.219 -		GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",37);
  17.220 -
  17.221 -	while ( timer_alive ) {
  17.222 -		if ( SDL_timer_running ) {
  17.223 -			SDL_ThreadedTimerCheck();
  17.224 -		}
  17.225 -		if(GfxBase)
  17.226 -			WaitTOF();  // Check the timer every fifth of seconds. Was SDL_Delay(1)->BusyWait!
  17.227 -		else
  17.228 -			Delay(1);
  17.229 -	}
  17.230 -	D(bug("SYSTimer: EXITING RunTimer loop..."));
  17.231 -	return(0);
  17.232 -}
  17.233 -
  17.234 -/* This is only called if the event thread is not running */
  17.235 -int SDL_SYS_TimerInit(void)
  17.236 -{
  17.237 -	D(bug("Creating thread for the timer (NOITIMER)...\n"));
  17.238 -
  17.239 -	timer_alive = 1;
  17.240 -	timer_thread = SDL_CreateThread(RunTimer, NULL);
  17.241 -	if ( timer_thread == NULL )
  17.242 -	{
  17.243 -		D(bug("Creazione del thread fallita...\n"));
  17.244 -
  17.245 -		return(-1);
  17.246 -	}
  17.247 -	return(SDL_SetTimerThreaded(1));
  17.248 -}
  17.249 -
  17.250 -void SDL_SYS_TimerQuit(void)
  17.251 -{
  17.252 -	timer_alive = 0;
  17.253 -	if ( timer_thread ) {
  17.254 -		SDL_WaitThread(timer_thread, NULL);
  17.255 -		timer_thread = NULL;
  17.256 -	}
  17.257 -}
  17.258 -
  17.259 -int SDL_SYS_StartTimer(void)
  17.260 -{
  17.261 -	SDL_SetError("Internal logic error: AmigaOS uses threaded timer");
  17.262 -	return(-1);
  17.263 -}
  17.264 -
  17.265 -void SDL_SYS_StopTimer(void)
  17.266 -{
  17.267 -	return;
  17.268 -}
  17.269 -
  17.270 -#endif /* SDL_TIMER_AMIGA */
    18.1 --- a/src/video/SDL_video.c	Sun Oct 29 03:44:25 2006 +0000
    18.2 +++ b/src/video/SDL_video.c	Sun Oct 29 03:58:27 2006 +0000
    18.3 @@ -90,9 +90,6 @@
    18.4  #if SDL_VIDEO_DRIVER_DRAWSPROCKET
    18.5  	&DSp_bootstrap,
    18.6  #endif
    18.7 -#if SDL_VIDEO_DRIVER_CYBERGRAPHICS
    18.8 -	&CGX_bootstrap,
    18.9 -#endif
   18.10  #if SDL_VIDEO_DRIVER_PHOTON
   18.11  	&ph_bootstrap,
   18.12  #endif
    19.1 --- a/src/video/cybergfx/SDL_amigaevents.c	Sun Oct 29 03:44:25 2006 +0000
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,535 +0,0 @@
    19.4 -/*
    19.5 -    SDL - Simple DirectMedia Layer
    19.6 -    Copyright (C) 1997-2006 Sam Lantinga
    19.7 -
    19.8 -    This library is free software; you can redistribute it and/or
    19.9 -    modify it under the terms of the GNU Lesser General Public
   19.10 -    License as published by the Free Software Foundation; either
   19.11 -    version 2.1 of the License, or (at your option) any later version.
   19.12 -
   19.13 -    This library is distributed in the hope that it will be useful,
   19.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   19.16 -    Lesser General Public License for more details.
   19.17 -
   19.18 -    You should have received a copy of the GNU Lesser General Public
   19.19 -    License along with this library; if not, write to the Free Software
   19.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   19.21 -
   19.22 -    Sam Lantinga
   19.23 -    slouken@libsdl.org
   19.24 -*/
   19.25 -#include "SDL_config.h"
   19.26 -
   19.27 -/* Handle the event stream, converting Amiga events into SDL events */
   19.28 -#include "SDL.h"
   19.29 -
   19.30 -#include "SDL_syswm.h"
   19.31 -#include "../SDL_sysvideo.h"
   19.32 -#include "../../events/SDL_sysevents.h"
   19.33 -#include "../../events/SDL_events_c.h"
   19.34 -#include "SDL_cgxvideo.h"
   19.35 -#include "SDL_cgxmodes_c.h"
   19.36 -#include "SDL_cgximage_c.h"
   19.37 -#include "SDL_cgxwm_c.h"
   19.38 -#include "SDL_amigaevents_c.h"
   19.39 -
   19.40 -
   19.41 -/* The translation tables from an Amiga keysym to a SDL keysym */
   19.42 -static SDLKey MISC_keymap[256];
   19.43 -SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym);
   19.44 -struct IOStdReq *ConReq=NULL;
   19.45 -struct MsgPort *ConPort=NULL;
   19.46 -
   19.47 -/* Note:  The X server buffers and accumulates mouse motion events, so
   19.48 -   the motion event generated by the warp may not appear exactly as we
   19.49 -   expect it to.  We work around this (and improve performance) by only
   19.50 -   warping the pointer when it reaches the edge, and then wait for it.
   19.51 -*/
   19.52 -#define MOUSE_FUDGE_FACTOR	8
   19.53 -
   19.54 -#if 0
   19.55 -
   19.56 -static inline int amiga_WarpedMotion(_THIS, struct IntuiMessage *m)
   19.57 -{
   19.58 -	int w, h, i;
   19.59 -	int deltax, deltay;
   19.60 -	int posted;
   19.61 -
   19.62 -	w = SDL_VideoSurface->w;
   19.63 -	h = SDL_VideoSurface->h;
   19.64 -	deltax = xevent->xmotion.x - mouse_last.x;
   19.65 -	deltay = xevent->xmotion.y - mouse_last.y;
   19.66 -#ifdef DEBUG_MOTION
   19.67 -  printf("Warped mouse motion: %d,%d\n", deltax, deltay);
   19.68 -#endif
   19.69 -	mouse_last.x = xevent->xmotion.x;
   19.70 -	mouse_last.y = xevent->xmotion.y;
   19.71 -	posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay);
   19.72 -
   19.73 -	if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) ||
   19.74 -	     (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) ||
   19.75 -	     (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
   19.76 -	     (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
   19.77 -		/* Get the events that have accumulated */
   19.78 -		while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
   19.79 -			deltax = xevent->xmotion.x - mouse_last.x;
   19.80 -			deltay = xevent->xmotion.y - mouse_last.y;
   19.81 -#ifdef DEBUG_MOTION
   19.82 -  printf("Extra mouse motion: %d,%d\n", deltax, deltay);
   19.83 -#endif
   19.84 -			mouse_last.x = xevent->xmotion.x;
   19.85 -			mouse_last.y = xevent->xmotion.y;
   19.86 -			posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay);
   19.87 -		}
   19.88 -		mouse_last.x = w/2;
   19.89 -		mouse_last.y = h/2;
   19.90 -		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
   19.91 -					mouse_last.x, mouse_last.y);
   19.92 -		for ( i=0; i<10; ++i ) {
   19.93 -        		XMaskEvent(SDL_Display, PointerMotionMask, xevent);
   19.94 -			if ( (xevent->xmotion.x >
   19.95 -			          (mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
   19.96 -			     (xevent->xmotion.x <
   19.97 -			          (mouse_last.x+MOUSE_FUDGE_FACTOR)) &&
   19.98 -			     (xevent->xmotion.y >
   19.99 -			          (mouse_last.y-MOUSE_FUDGE_FACTOR)) &&
  19.100 -			     (xevent->xmotion.y <
  19.101 -			          (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) {
  19.102 -				break;
  19.103 -			}
  19.104 -#ifdef DEBUG_XEVENTS
  19.105 -  printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y);
  19.106 -#endif
  19.107 -		}
  19.108 -#ifdef DEBUG_XEVENTS
  19.109 -		if ( i == 10 ) {
  19.110 -			printf("Warning: didn't detect mouse warp motion\n");
  19.111 -		}
  19.112 -#endif
  19.113 -	}
  19.114 -	return(posted);
  19.115 -}
  19.116 -
  19.117 -#endif
  19.118 -
  19.119 -static int amiga_GetButton(int code)
  19.120 -{
  19.121 -	switch(code)
  19.122 -	{
  19.123 -		case IECODE_MBUTTON:
  19.124 -			return SDL_BUTTON_MIDDLE;
  19.125 -		case IECODE_RBUTTON:
  19.126 -			return SDL_BUTTON_RIGHT;
  19.127 -		default:
  19.128 -			return SDL_BUTTON_LEFT;
  19.129 -	}
  19.130 -}
  19.131 -
  19.132 -static int amiga_DispatchEvent(_THIS,struct IntuiMessage *msg)
  19.133 -{
  19.134 -	int class=msg->Class,code=msg->Code;
  19.135 -	int posted;
  19.136 -
  19.137 -	posted = 0;
  19.138 -	switch (class) {
  19.139 -	    /* Gaining mouse coverage? */
  19.140 -	    case IDCMP_ACTIVEWINDOW:
  19.141 -			posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
  19.142 -			break;
  19.143 -
  19.144 -	    /* Losing mouse coverage? */
  19.145 -	    case IDCMP_INACTIVEWINDOW:
  19.146 -			posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
  19.147 -			break;
  19.148 -#if 0
  19.149 -	    /* Gaining input focus? */
  19.150 -	    case IDCMP_ACTIVEWINDOW:
  19.151 -			posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
  19.152 -
  19.153 -			/* Queue entry into fullscreen mode */
  19.154 -			switch_waiting = 0x01 | SDL_FULLSCREEN;
  19.155 -			switch_time = SDL_GetTicks() + 1500;
  19.156 -		    break;
  19.157 -
  19.158 -	    /* Losing input focus? */
  19.159 -	    case IDCMP_INACTIVEWINDOW:
  19.160 -			posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
  19.161 -
  19.162 -		/* Queue leaving fullscreen mode */
  19.163 -			switch_waiting = 0x01;
  19.164 -			switch_time = SDL_GetTicks() + 200;
  19.165 -		    break;
  19.166 -#endif
  19.167 -	    /* Mouse motion? */
  19.168 -	    case IDCMP_MOUSEMOVE:
  19.169 -			if ( SDL_VideoSurface ) {
  19.170 -				posted = SDL_PrivateMouseMotion(0, 0,
  19.171 -						msg->MouseX-SDL_Window->BorderLeft,
  19.172 -						msg->MouseY-SDL_Window->BorderTop);
  19.173 -			}
  19.174 -	    	break;
  19.175 -
  19.176 -	    /* Mouse button press? */
  19.177 -		case IDCMP_MOUSEBUTTONS:
  19.178 -
  19.179 -			if(!(code&IECODE_UP_PREFIX))
  19.180 -			{
  19.181 -				posted = SDL_PrivateMouseButton(SDL_PRESSED,
  19.182 -						amiga_GetButton(code), 0, 0);
  19.183 -			    }
  19.184 -	    /* Mouse button release? */
  19.185 -			else
  19.186 -			{
  19.187 -				code&=~IECODE_UP_PREFIX;
  19.188 -				posted = SDL_PrivateMouseButton(SDL_RELEASED,
  19.189 -						amiga_GetButton(code), 0, 0);
  19.190 -			}
  19.191 -			break;
  19.192 -
  19.193 -	    case IDCMP_RAWKEY:
  19.194 -
  19.195 -		    /* Key press? */
  19.196 -
  19.197 -		    if( !(code&IECODE_UP_PREFIX) )
  19.198 -		    {
  19.199 -				SDL_keysym keysym;
  19.200 -				posted = SDL_PrivateKeyboard(SDL_PRESSED,
  19.201 -					amiga_TranslateKey(code, &keysym));
  19.202 -		    }
  19.203 -		    else
  19.204 -		    {
  19.205 -	    /* Key release? */
  19.206 -
  19.207 -				SDL_keysym keysym;
  19.208 -				code&=~IECODE_UP_PREFIX;
  19.209 -
  19.210 -			/* Check to see if this is a repeated key */
  19.211 -/*			if ( ! X11_KeyRepeat(SDL_Display, &xevent) )  */
  19.212 -
  19.213 -				posted = SDL_PrivateKeyboard(SDL_RELEASED,
  19.214 -					amiga_TranslateKey(code, &keysym));
  19.215 -		    }
  19.216 -		    break;
  19.217 -	    /* Have we been iconified? */
  19.218 -#if 0
  19.219 -	    case UnmapNotify: {
  19.220 -#ifdef DEBUG_XEVENTS
  19.221 -printf("UnmapNotify!\n");
  19.222 -#endif
  19.223 -		posted=SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS);
  19.224 -	    }
  19.225 -	    break;
  19.226 -
  19.227 -	    /* Have we been restored? */
  19.228 -
  19.229 -	    case MapNotify: {
  19.230 -#ifdef DEBUG_XEVENTS
  19.231 -printf("MapNotify!\n");
  19.232 -#endif
  19.233 -
  19.234 -		posted = SDL_PrivateAppActive(1, SDL_APPACTIVE);
  19.235 -
  19.236 -		if ( SDL_VideoSurface &&
  19.237 -		     (SDL_VideoSurface->flags & SDL_FULLSCREEN) )
  19.238 -		{
  19.239 -			CGX_EnterFullScreen(this);
  19.240 -		} else {
  19.241 -			X11_GrabInputNoLock(this, this->input_grab);
  19.242 -		}
  19.243 -		if ( SDL_VideoSurface ) {
  19.244 -			CGX_RefreshDisplay(this);
  19.245 -		}
  19.246 -	    }
  19.247 -	    break;
  19.248 -	    case Expose:
  19.249 -		if ( SDL_VideoSurface && (xevent.xexpose.count == 0) ) {
  19.250 -			CGX_RefreshDisplay(this);
  19.251 -		}
  19.252 -		break;
  19.253 -#endif
  19.254 -
  19.255 -	    /* Have we been resized? */
  19.256 -	    case IDCMP_NEWSIZE:
  19.257 -			SDL_PrivateResize(SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight,
  19.258 -		                  SDL_Window->Height-SDL_Window->BorderTop-SDL_Window->BorderBottom);
  19.259 -
  19.260 -			break;
  19.261 -
  19.262 -	    /* Have we been requested to quit? */
  19.263 -	    case IDCMP_CLOSEWINDOW:
  19.264 -		posted = SDL_PrivateQuit();
  19.265 -		break;
  19.266 -
  19.267 -	    /* Do we need to refresh ourselves? */
  19.268 -
  19.269 -	    default: {
  19.270 -		/* Only post the event if we're watching for it */
  19.271 -		if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
  19.272 -			SDL_SysWMmsg wmmsg;
  19.273 -
  19.274 -			SDL_VERSION(&wmmsg.version);
  19.275 -#if 0
  19.276 -			wmmsg.subsystem = SDL_SYSWM_CGX;
  19.277 -			wmmsg.event.xevent = xevent;
  19.278 -#endif
  19.279 -			posted = SDL_PrivateSysWMEvent(&wmmsg);
  19.280 -		}
  19.281 -	    }
  19.282 -	    break;
  19.283 -	}
  19.284 -	ReplyMsg((struct Message *)msg);
  19.285 -
  19.286 -
  19.287 -	return(posted);
  19.288 -}
  19.289 -
  19.290 -void amiga_PumpEvents(_THIS)
  19.291 -{
  19.292 -	int pending;
  19.293 -	struct IntuiMessage *m;
  19.294 -
  19.295 -	/* Keep processing pending events */
  19.296 -	pending = 0;
  19.297 -	while ( m=(struct IntuiMessage *)GetMsg(SDL_Window->UserPort) ) {
  19.298 -		amiga_DispatchEvent(this,m);
  19.299 -		++pending;
  19.300 -	}
  19.301 -}
  19.302 -
  19.303 -void amiga_InitKeymap(void)
  19.304 -{
  19.305 -	int i;
  19.306 -
  19.307 -	/* Map the miscellaneous keys */
  19.308 -	for ( i=0; i<SDL_arraysize(MISC_keymap); ++i )
  19.309 -		MISC_keymap[i] = SDLK_UNKNOWN;
  19.310 -
  19.311 -	/* These X keysyms have 0xFF as the high byte */
  19.312 -	MISC_keymap[65] = SDLK_BACKSPACE;
  19.313 -	MISC_keymap[66] = SDLK_TAB;
  19.314 -	MISC_keymap[70] = SDLK_CLEAR;
  19.315 -	MISC_keymap[70] = SDLK_DELETE;
  19.316 -	MISC_keymap[68] = SDLK_RETURN;
  19.317 -//	MISC_keymap[XK_Pause&0xFF] = SDLK_PAUSE;
  19.318 -	MISC_keymap[69] = SDLK_ESCAPE;
  19.319 -	MISC_keymap[70] = SDLK_DELETE;
  19.320 -/*
  19.321 -	SDLK_SPACE		= 32,
  19.322 -	SDLK_MINUS		= 45,
  19.323 -	SDLK_LESS		= 60,
  19.324 -	SDLK_COMMA		= 44,
  19.325 -	SDLK_PERIOD		= 46,
  19.326 -	SDLK_0			= 48,
  19.327 -	SDLK_1			= 49,
  19.328 -	SDLK_2			= 50,
  19.329 -	SDLK_3			= 51,
  19.330 -	SDLK_4			= 52,
  19.331 -	SDLK_5			= 53,
  19.332 -	SDLK_6			= 54,
  19.333 -	SDLK_7			= 55,
  19.334 -	SDLK_8			= 56,
  19.335 -	SDLK_9			= 57,
  19.336 -	SDLK_BACKQUOTE		= 96,
  19.337 -	SDLK_BACKSLASH		= 92,
  19.338 -	SDLK_a			= 97,
  19.339 -	SDLK_b			= 98,
  19.340 -	SDLK_c			= 99,
  19.341 -	SDLK_d			= 100,
  19.342 -	SDLK_e			= 101,
  19.343 -	SDLK_f			= 102,
  19.344 -	SDLK_g			= 103,
  19.345 -	SDLK_h			= 104,
  19.346 -	SDLK_i			= 105,
  19.347 -	SDLK_j			= 106,
  19.348 -	SDLK_k			= 107,
  19.349 -	SDLK_l			= 108,
  19.350 -	SDLK_m			= 109,
  19.351 -	SDLK_n			= 110,
  19.352 -	SDLK_o			= 111,
  19.353 -	SDLK_p			= 112,
  19.354 -	SDLK_q			= 113,
  19.355 -	SDLK_r			= 114,
  19.356 -	SDLK_s			= 115,
  19.357 -	SDLK_t			= 116,
  19.358 -	SDLK_u			= 117,
  19.359 -	SDLK_v			= 118,
  19.360 -	SDLK_w			= 119,
  19.361 -	SDLK_x			= 120,
  19.362 -	SDLK_y			= 121,
  19.363 -	SDLK_z			= 122,
  19.364 -*/
  19.365 -	MISC_keymap[15] = SDLK_KP0;		/* Keypad 0-9 */
  19.366 -	MISC_keymap[29] = SDLK_KP1;
  19.367 -	MISC_keymap[30] = SDLK_KP2;
  19.368 -	MISC_keymap[31] = SDLK_KP3;
  19.369 -	MISC_keymap[45] = SDLK_KP4;
  19.370 -	MISC_keymap[46] = SDLK_KP5;
  19.371 -	MISC_keymap[47] = SDLK_KP6;
  19.372 -	MISC_keymap[61] = SDLK_KP7;
  19.373 -	MISC_keymap[62] = SDLK_KP8;
  19.374 -	MISC_keymap[63] = SDLK_KP9;
  19.375 -	MISC_keymap[60] = SDLK_KP_PERIOD;
  19.376 -	MISC_keymap[92] = SDLK_KP_DIVIDE;
  19.377 -	MISC_keymap[93] = SDLK_KP_MULTIPLY;
  19.378 -	MISC_keymap[74] = SDLK_KP_MINUS;
  19.379 -	MISC_keymap[94] = SDLK_KP_PLUS;
  19.380 -	MISC_keymap[67] = SDLK_KP_ENTER;
  19.381 -//	MISC_keymap[XK_KP_Equal&0xFF] = SDLK_KP_EQUALS;
  19.382 -
  19.383 -	MISC_keymap[76] = SDLK_UP;
  19.384 -	MISC_keymap[77] = SDLK_DOWN;
  19.385 -	MISC_keymap[78] = SDLK_RIGHT;
  19.386 -	MISC_keymap[79] = SDLK_LEFT;
  19.387 -/*
  19.388 -	MISC_keymap[XK_Insert&0xFF] = SDLK_INSERT;
  19.389 -	MISC_keymap[XK_Home&0xFF] = SDLK_HOME;
  19.390 -	MISC_keymap[XK_End&0xFF] = SDLK_END;
  19.391 -*/
  19.392 -// Mappati sulle parentesi del taastierino
  19.393 -	MISC_keymap[90] = SDLK_PAGEUP;
  19.394 -	MISC_keymap[91] = SDLK_PAGEDOWN;
  19.395 -
  19.396 -	MISC_keymap[80] = SDLK_F1;
  19.397 -	MISC_keymap[81] = SDLK_F2;
  19.398 -	MISC_keymap[82] = SDLK_F3;
  19.399 -	MISC_keymap[83] = SDLK_F4;
  19.400 -	MISC_keymap[84] = SDLK_F5;
  19.401 -	MISC_keymap[85] = SDLK_F6;
  19.402 -	MISC_keymap[86] = SDLK_F7;
  19.403 -	MISC_keymap[87] = SDLK_F8;
  19.404 -	MISC_keymap[88] = SDLK_F9;
  19.405 -	MISC_keymap[89] = SDLK_F10;
  19.406 -//	MISC_keymap[XK_F11&0xFF] = SDLK_F11;
  19.407 -//	MISC_keymap[XK_F12&0xFF] = SDLK_F12;
  19.408 -//	MISC_keymap[XK_F13&0xFF] = SDLK_F13;
  19.409 -//	MISC_keymap[XK_F14&0xFF] = SDLK_F14;
  19.410 -//	MISC_keymap[XK_F15&0xFF] = SDLK_F15;
  19.411 -
  19.412 -//	MISC_keymap[XK_Num_Lock&0xFF] = SDLK_NUMLOCK;
  19.413 -	MISC_keymap[98] = SDLK_CAPSLOCK;
  19.414 -//	MISC_keymap[XK_Scroll_Lock&0xFF] = SDLK_SCROLLOCK;
  19.415 -	MISC_keymap[97] = SDLK_RSHIFT;
  19.416 -	MISC_keymap[96] = SDLK_LSHIFT;
  19.417 -	MISC_keymap[99] = SDLK_LCTRL;
  19.418 -	MISC_keymap[99] = SDLK_LCTRL;
  19.419 -	MISC_keymap[101] = SDLK_RALT;
  19.420 -	MISC_keymap[100] = SDLK_LALT;
  19.421 -//	MISC_keymap[XK_Meta_R&0xFF] = SDLK_RMETA;
  19.422 -//	MISC_keymap[XK_Meta_L&0xFF] = SDLK_LMETA;
  19.423 -	MISC_keymap[103] = SDLK_LSUPER; /* Left "Windows" */
  19.424 -	MISC_keymap[102] = SDLK_RSUPER; /* Right "Windows */
  19.425 -
  19.426 -	MISC_keymap[95] = SDLK_HELP;
  19.427 -}
  19.428 -
  19.429 -SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym)
  19.430 -{
  19.431 -	#ifdef STORMC4_WOS
  19.432 -	static struct Library *KeymapBase=NULL; /* Linking failed in WOS version if ConsoleDevice was used */
  19.433 -	#else
  19.434 -	static struct Library *ConsoleDevice=NULL;
  19.435 -	#endif
  19.436 -
  19.437 -	/* Get the raw keyboard scancode */
  19.438 -	keysym->scancode = code;
  19.439 -	keysym->sym = MISC_keymap[code];
  19.440 -
  19.441 -#ifdef DEBUG_KEYS
  19.442 -	fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode);
  19.443 -#endif
  19.444 -	/* Get the translated SDL virtual keysym */
  19.445 -	if ( keysym->sym==SDLK_UNKNOWN )
  19.446 -	{
  19.447 -		#ifdef STORMC4_WOS
  19.448 -		if(!KeymapBase)
  19.449 -		#else
  19.450 -		if(!ConsoleDevice)
  19.451 -		#endif
  19.452 -		{
  19.453 -			#ifdef STORMC4_WOS
  19.454 -			KeymapBase=OpenLibrary("keymap.library", 0L);
  19.455 -			#else
  19.456 -			if(ConPort=CreateMsgPort())
  19.457 -			{
  19.458 -				if(ConReq=CreateIORequest(ConPort,sizeof(struct IOStdReq)))
  19.459 -				{
  19.460 -					if(!OpenDevice("console.device",-1,(struct IORequest *)ConReq,0))
  19.461 -						ConsoleDevice=(struct Library *)ConReq->io_Device;
  19.462 -					else
  19.463 -					{
  19.464 -						DeleteIORequest(ConReq);
  19.465 -						ConReq=NULL;
  19.466 -					}
  19.467 -				}
  19.468 -				else
  19.469 -				{
  19.470 -					DeleteMsgPort(ConPort);
  19.471 -					ConPort=NULL;
  19.472 -				}
  19.473 -			}
  19.474 -			#endif
  19.475 -		}
  19.476 -
  19.477 -		#ifdef STORMC4_WOS
  19.478 -		if(KeymapBase)
  19.479 -		#else
  19.480 -		if(ConsoleDevice)
  19.481 -		#endif
  19.482 -		{
  19.483 -			struct InputEvent event;
  19.484 -			long actual;
  19.485 -			char buffer[5];
  19.486 -
  19.487 -			event.ie_Qualifier=0;
  19.488 -			event.ie_Class=IECLASS_RAWKEY;
  19.489 -			event.ie_SubClass=0L;
  19.490 -			event.ie_Code=code;
  19.491 -			event.ie_X=event.ie_Y=0;
  19.492 -			event.ie_EventAddress=NULL;
  19.493 -			event.ie_NextEvent=NULL;
  19.494 -			event.ie_Prev1DownCode=event.ie_Prev1DownQual=event.ie_Prev2DownCode=event.ie_Prev2DownQual=0;
  19.495 -
  19.496 -			#ifdef STORMC4_WOS
  19.497 -			if( (actual=MapRawKey(&event,buffer,5,NULL))>=0)
  19.498 -			#else
  19.499 -			if( (actual=RawKeyConvert(&event,buffer,5,NULL))>=0)
  19.500 -			#endif
  19.501 -			{
  19.502 -				if(actual>1)
  19.503 -				{
  19.504 -					D(bug("Warning (%ld) character conversion!\n",actual));
  19.505 -				}
  19.506 -				else if(actual==1)
  19.507 -				{
  19.508 -					keysym->sym=*buffer;
  19.509 -					D(bug("Converted rawcode %ld to <%lc>\n",code,*buffer));
  19.510 -// Bufferizzo x le successive chiamate!
  19.511 -					MISC_keymap[code]=*buffer;
  19.512 -				}
  19.513 -			}
  19.514 -		}
  19.515 -
  19.516 -	}
  19.517 -	keysym->mod = KMOD_NONE;
  19.518 -
  19.519 -	/* If UNICODE is on, get the UNICODE value for the key */
  19.520 -	keysym->unicode = 0;
  19.521 -	if ( SDL_TranslateUNICODE ) {
  19.522 -#if 0
  19.523 -		static XComposeStatus state;
  19.524 -		/* Until we handle the IM protocol, use XLookupString() */
  19.525 -		unsigned char keybuf[32];
  19.526 -		if ( XLookupString(xkey, (char *)keybuf, sizeof(keybuf),
  19.527 -							NULL, &state) ) {
  19.528 -			keysym->unicode = keybuf[0];
  19.529 -		}
  19.530 -#endif
  19.531 -	}
  19.532 -	return(keysym);
  19.533 -}
  19.534 -
  19.535 -void amiga_InitOSKeymap(_THIS)
  19.536 -{
  19.537 -	amiga_InitKeymap();
  19.538 -}
    20.1 --- a/src/video/cybergfx/SDL_amigaevents_c.h	Sun Oct 29 03:44:25 2006 +0000
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,29 +0,0 @@
    20.4 -/*
    20.5 -    SDL - Simple DirectMedia Layer
    20.6 -    Copyright (C) 1997-2006 Sam Lantinga
    20.7 -
    20.8 -    This library is free software; you can redistribute it and/or
    20.9 -    modify it under the terms of the GNU Lesser General Public
   20.10 -    License as published by the Free Software Foundation; either
   20.11 -    version 2.1 of the License, or (at your option) any later version.
   20.12 -
   20.13 -    This library is distributed in the hope that it will be useful,
   20.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.16 -    Lesser General Public License for more details.
   20.17 -
   20.18 -    You should have received a copy of the GNU Lesser General Public
   20.19 -    License along with this library; if not, write to the Free Software
   20.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   20.21 -
   20.22 -    Sam Lantinga
   20.23 -    slouken@libsdl.org
   20.24 -*/
   20.25 -#include "SDL_config.h"
   20.26 -
   20.27 -#include "SDL_cgxvideo.h"
   20.28 -
   20.29 -/* Functions to be exported */
   20.30 -extern void amiga_InitOSKeymap(_THIS);
   20.31 -extern void amiga_PumpEvents(_THIS);
   20.32 -
    21.1 --- a/src/video/cybergfx/SDL_amigamouse.c	Sun Oct 29 03:44:25 2006 +0000
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,77 +0,0 @@
    21.4 -/*
    21.5 -    SDL - Simple DirectMedia Layer
    21.6 -    Copyright (C) 1997-2006 Sam Lantinga
    21.7 -
    21.8 -    This library is free software; you can redistribute it and/or
    21.9 -    modify it under the terms of the GNU Lesser General Public
   21.10 -    License as published by the Free Software Foundation; either
   21.11 -    version 2.1 of the License, or (at your option) any later version.
   21.12 -
   21.13 -    This library is distributed in the hope that it will be useful,
   21.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21.16 -    Lesser General Public License for more details.
   21.17 -
   21.18 -    You should have received a copy of the GNU Lesser General Public
   21.19 -    License along with this library; if not, write to the Free Software
   21.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   21.21 -
   21.22 -    Sam Lantinga
   21.23 -    slouken@libsdl.org
   21.24 -*/
   21.25 -#include "SDL_config.h"
   21.26 -
   21.27 -#include "SDL_mouse.h"
   21.28 -#include "../../events/SDL_events_c.h"
   21.29 -#include "../SDL_cursor_c.h"
   21.30 -#include "SDL_amigamouse_c.h"
   21.31 -
   21.32 -
   21.33 -/* The implementation dependent data for the window manager cursor */
   21.34 -
   21.35 -typedef void * WMCursor;
   21.36 -
   21.37 -void amiga_FreeWMCursor(_THIS, WMcursor *cursor)
   21.38 -{
   21.39 -}
   21.40 -
   21.41 -WMcursor *amiga_CreateWMCursor(_THIS,
   21.42 -		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
   21.43 -{
   21.44 -	return (WMcursor *)1; // Amiga has an Hardware cursor, so it's ok to return something unuseful but true
   21.45 -}
   21.46 -
   21.47 -int amiga_ShowWMCursor(_THIS, WMcursor *cursor)
   21.48 -{
   21.49 -	/* Don't do anything if the display is gone */
   21.50 -	if ( SDL_Display == NULL) {
   21.51 -		return(0);
   21.52 -	}
   21.53 -
   21.54 -	/* Set the Amiga prefs cursor cursor, or blank if cursor is NULL */
   21.55 -
   21.56 -	if ( SDL_Window ) {
   21.57 -		SDL_Lock_EventThread();
   21.58 -		if ( cursor == NULL ) {
   21.59 -			if ( SDL_BlankCursor != NULL ) {
   21.60 -// Hide cursor HERE
   21.61 -				SetPointer(SDL_Window,(UWORD *)SDL_BlankCursor,1,1,0,0);
   21.62 -			}
   21.63 -		} else {
   21.64 -// Show cursor
   21.65 -			ClearPointer(SDL_Window);
   21.66 -		}
   21.67 -		SDL_Unlock_EventThread();
   21.68 -	}
   21.69 -	return(1);
   21.70 -}
   21.71 -
   21.72 -void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
   21.73 -{
   21.74 -/* FIXME: Not implemented */
   21.75 -}
   21.76 -
   21.77 -/* Check to see if we need to enter or leave mouse relative mode */
   21.78 -void amiga_CheckMouseMode(_THIS)
   21.79 -{
   21.80 -}
    22.1 --- a/src/video/cybergfx/SDL_amigamouse_c.h	Sun Oct 29 03:44:25 2006 +0000
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,32 +0,0 @@
    22.4 -/*
    22.5 -    SDL - Simple DirectMedia Layer
    22.6 -    Copyright (C) 1997-2006 Sam Lantinga
    22.7 -
    22.8 -    This library is free software; you can redistribute it and/or
    22.9 -    modify it under the terms of the GNU Lesser General Public
   22.10 -    License as published by the Free Software Foundation; either
   22.11 -    version 2.1 of the License, or (at your option) any later version.
   22.12 -
   22.13 -    This library is distributed in the hope that it will be useful,
   22.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22.16 -    Lesser General Public License for more details.
   22.17 -
   22.18 -    You should have received a copy of the GNU Lesser General Public
   22.19 -    License along with this library; if not, write to the Free Software
   22.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   22.21 -
   22.22 -    Sam Lantinga
   22.23 -    slouken@libsdl.org
   22.24 -*/
   22.25 -#include "SDL_config.h"
   22.26 -
   22.27 -#include "SDL_cgxvideo.h"
   22.28 -
   22.29 -/* Functions to be exported */
   22.30 -extern void amiga_FreeWMCursor(_THIS, WMcursor *cursor);
   22.31 -extern WMcursor *amiga_CreateWMCursor(_THIS,
   22.32 -		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
   22.33 -extern int amiga_ShowWMCursor(_THIS, WMcursor *cursor);
   22.34 -extern void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
   22.35 -extern void amiga_CheckMouseMode(_THIS);
    23.1 --- a/src/video/cybergfx/SDL_cgxaccel.c	Sun Oct 29 03:44:25 2006 +0000
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,262 +0,0 @@
    23.4 -/*
    23.5 -    SDL - Simple DirectMedia Layer
    23.6 -    Copyright (C) 1997-2006 Sam Lantinga
    23.7 -
    23.8 -    This library is free software; you can redistribute it and/or
    23.9 -    modify it under the terms of the GNU Lesser General Public
   23.10 -    License as published by the Free Software Foundation; either
   23.11 -    version 2.1 of the License, or (at your option) any later version.
   23.12 -
   23.13 -    This library is distributed in the hope that it will be useful,
   23.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   23.16 -    Lesser General Public License for more details.
   23.17 -
   23.18 -    You should have received a copy of the GNU Lesser General Public
   23.19 -    License along with this library; if not, write to the Free Software
   23.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   23.21 -
   23.22 -    Sam Lantinga
   23.23 -    slouken@libsdl.org
   23.24 -*/
   23.25 -#include "SDL_config.h"
   23.26 -
   23.27 -#include "SDL_endian.h"
   23.28 -#include "SDL_video.h"
   23.29 -#include "../SDL_sysvideo.h"
   23.30 -#include "../SDL_blit.h"
   23.31 -#include "SDL_cgxvideo.h"
   23.32 -
   23.33 -static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
   23.34 -					SDL_Surface *dst, SDL_Rect *dstrect);
   23.35 -
   23.36 -// These are needed to avoid register troubles with gcc -O2!
   23.37 -
   23.38 -#if defined(__SASC) || defined(__PPC__) || defined(MORPHOS)
   23.39 -#define BMKBRP(a,b,c,d,e,f,g,h,i,j) BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j)
   23.40 -#define	BBRP(a,b,c,d,e,f,g,h,i) BltBitMapRastPort(a,b,c,d,e,f,g,h,i)
   23.41 -#define BBB(a,b,c,d,e,f,g,h,i,j,k) BltBitMap(a,b,c,d,e,f,g,h,i,j,k)
   23.42 -#else
   23.43 -void BMKBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,APTR j)
   23.44 -{BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j);}
   23.45 -
   23.46 -void BBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i)
   23.47 -{BltBitMapRastPort(a,b,c,d,e,f,g,h,i);}
   23.48 -
   23.49 -void BBB(struct BitMap *a,WORD b, WORD c,struct BitMap *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,UBYTE j,UWORD *k)
   23.50 -{BltBitMap(a,b,c,d,e,f,g,h,i,j,k);}
   23.51 -#endif
   23.52 -
   23.53 -int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key)
   23.54 -{
   23.55 -	if(surface->hwdata)
   23.56 -	{
   23.57 -		if(surface->hwdata->mask)
   23.58 -			SDL_free(surface->hwdata->mask);
   23.59 -
   23.60 -		if(surface->hwdata->mask=SDL_malloc(RASSIZE(surface->w,surface->h)))
   23.61 -		{
   23.62 -			Uint32 pitch,ok=0;
   23.63 -			APTR lock;
   23.64 -
   23.65 -			SDL_memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h));
   23.66 -
   23.67 -			D(bug("Building colorkey mask: color: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n",key,surface->w,surface->h,RASSIZE(surface->w,surface->h),surface->format->BytesPerPixel));
   23.68 -
   23.69 -			if(lock=LockBitMapTags(surface->hwdata->bmap,LBMI_BASEADDRESS,(ULONG)&surface->pixels,
   23.70 -					LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))
   23.71 -			{
   23.72 -				switch(surface->format->BytesPerPixel)
   23.73 -				{
   23.74 -					case 1:
   23.75 -					{
   23.76 -						unsigned char k=key;
   23.77 -						register int i,j,t;
   23.78 -						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;
   23.79 -
   23.80 -						pitch-=surface->w;
   23.81 -
   23.82 -						for(i=0;i<surface->h;i++)
   23.83 -						{
   23.84 -							for(t=128,j=0;j<surface->w;j++)
   23.85 -							{
   23.86 -								if(*map==k)
   23.87 -									*dest&=~t;	
   23.88 -
   23.89 -								t>>=1;
   23.90 -
   23.91 -								if(t==0)
   23.92 -								{
   23.93 -									dest++;
   23.94 -									t=128;
   23.95 -								}
   23.96 -								map++;
   23.97 -							}
   23.98 -							map+=pitch;
   23.99 -						}
  23.100 -					}
  23.101 -					break;
  23.102 -					case 2:
  23.103 -					{
  23.104 -						Uint16 k=key,*mapw;
  23.105 -						register int i,j,t;
  23.106 -						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;
  23.107 -
  23.108 -						for(i=surface->h;i;--i)
  23.109 -						{
  23.110 -							mapw=(Uint16 *)map;
  23.111 -
  23.112 -							for(t=128,j=surface->w;j;--j)
  23.113 -							{
  23.114 -								if(*mapw==k)
  23.115 -									*dest&=~t;
  23.116 -
  23.117 -								t>>=1;
  23.118 -
  23.119 -								if(t==0)
  23.120 -								{
  23.121 -									dest++;
  23.122 -									t=128;
  23.123 -								}
  23.124 -								mapw++;
  23.125 -							}
  23.126 -							map+=pitch;
  23.127 -						}
  23.128 -					}
  23.129 -					break;
  23.130 -					case 4:
  23.131 -					{
  23.132 -						Uint32 *mapl;
  23.133 -						register int i,j,t;
  23.134 -						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;
  23.135 -
  23.136 -						for(i=surface->h;i;--i)
  23.137 -						{
  23.138 -							mapl=(Uint32 *)map;
  23.139 -
  23.140 -							for(t=128,j=surface->w;j;--j)
  23.141 -							{
  23.142 -								if(*mapl==key)
  23.143 -									*dest&=~t;
  23.144 -
  23.145 -								t>>=1;
  23.146 -
  23.147 -								if(t==0)
  23.148 -								{
  23.149 -									dest++;
  23.150 -									t=128;
  23.151 -								}
  23.152 -								mapl++;
  23.153 -							}
  23.154 -							map+=pitch;
  23.155 -						}
  23.156 -
  23.157 -					}
  23.158 -					break;
  23.159 -					default:
  23.160 -						D(bug("Pixel mode non supported for color key..."));
  23.161 -						SDL_free(surface->hwdata->mask);
  23.162 -						surface->hwdata->mask=NULL;
  23.163 -						ok=-1;
  23.164 -				}
  23.165 -				UnLockBitMap(lock);
  23.166 -				D(bug("...Colorkey built!\n"));
  23.167 -				return ok;
  23.168 -			}
  23.169 -		}
  23.170 -	}
  23.171 -	D(bug("HW colorkey not supported for this depth\n"));
  23.172 -
  23.173 -	return -1;
  23.174 -}
  23.175 -
  23.176 -int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst)
  23.177 -{
  23.178 -// Doesn't support yet alpha blitting
  23.179 -
  23.180 -	if(src->hwdata&& !(src->flags & (SDL_SRCALPHA)))
  23.181 -	{
  23.182 -		D(bug("CheckHW blit... OK!\n"));
  23.183 -
  23.184 -		if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
  23.185 -			if ( CGX_SetHWColorKey(this, src, src->format->colorkey) < 0 ) {
  23.186 -				src->flags &= ~SDL_HWACCEL;
  23.187 -				return -1;
  23.188 -			}
  23.189 -		}
  23.190 -
  23.191 -		src->flags|=SDL_HWACCEL;
  23.192 -		src->map->hw_blit = CGX_HWAccelBlit;
  23.193 -		return 1;
  23.194 -	}
  23.195 -	else
  23.196 -		src->flags &= ~SDL_HWACCEL;
  23.197 -
  23.198 -	D(bug("CheckHW blit... NO!\n"));
  23.199 -
  23.200 -	return 0;
  23.201 -}
  23.202 -
  23.203 -static int temprp_init=0;
  23.204 -static struct RastPort temprp;
  23.205 -
  23.206 -static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
  23.207 -					SDL_Surface *dst, SDL_Rect *dstrect)
  23.208 -{
  23.209 -	struct SDL_VideoDevice *this=src->hwdata->videodata;
  23.210 -
  23.211 -//	D(bug("Accel blit!\n"));
  23.212 -
  23.213 -	if(src->flags&SDL_SRCCOLORKEY && src->hwdata->mask)
  23.214 -	{
  23.215 -		if(dst==SDL_VideoSurface)
  23.216 -		{
  23.217 -			BMKBRP(src->hwdata->bmap,srcrect->x,srcrect->y,
  23.218 -						SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,
  23.219 -						srcrect->w,srcrect->h,0xc0,src->hwdata->mask);
  23.220 -		}
  23.221 -		else if(dst->hwdata)
  23.222 -		{
  23.223 -			if(!temprp_init)
  23.224 -			{
  23.225 -				InitRastPort(&temprp);
  23.226 -				temprp_init=1;
  23.227 -			}
  23.228 -			temprp.BitMap=(struct BitMap *)dst->hwdata->bmap;
  23.229 -
  23.230 -			BMKBRP(src->hwdata->bmap,srcrect->x,srcrect->y,
  23.231 -						&temprp,dstrect->x,dstrect->y,
  23.232 -						srcrect->w,srcrect->h,0xc0,src->hwdata->mask);
  23.233 -			
  23.234 -		}
  23.235 -	}
  23.236 -	else if(dst==SDL_VideoSurface)
  23.237 -	{
  23.238 -		BBRP(src->hwdata->bmap,srcrect->x,srcrect->y,SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,srcrect->w,srcrect->h,0xc0);
  23.239 -	}
  23.240 -	else if(dst->hwdata)
  23.241 -		BBB(src->hwdata->bmap,srcrect->x,srcrect->y,dst->hwdata->bmap,dstrect->x,dstrect->y,srcrect->w,srcrect->h,0xc0,0xff,NULL);
  23.242 -
  23.243 -	return 0;
  23.244 -}
  23.245 -
  23.246 -int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color)
  23.247 -{
  23.248 -	if(dst==SDL_VideoSurface)
  23.249 -	{
  23.250 -		FillPixelArray(SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,dstrect->w,dstrect->h,color);
  23.251 -	}
  23.252 -	else if(dst->hwdata)
  23.253 -	{
  23.254 -		if(!temprp_init)
  23.255 -		{
  23.256 -			InitRastPort(&temprp);
  23.257 -			temprp_init=1;
  23.258 -		}
  23.259 -
  23.260 -		temprp.BitMap=(struct BitMap *)dst->hwdata->bmap;
  23.261 -
  23.262 -		FillPixelArray(&temprp,dstrect->x,dstrect->y,dstrect->w,dstrect->h,color);
  23.263 -	}
  23.264 -	return 0;
  23.265 -}
    24.1 --- a/src/video/cybergfx/SDL_cgxgl.c	Sun Oct 29 03:44:25 2006 +0000
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,212 +0,0 @@
    24.4 -/*
    24.5 -    SDL - Simple DirectMedia Layer
    24.6 -    Copyright (C) 1997-2006 Sam Lantinga
    24.7 -
    24.8 -    This library is free software; you can redistribute it and/or
    24.9 -    modify it under the terms of the GNU Lesser General Public
   24.10 -    License as published by the Free Software Foundation; either
   24.11 -    version 2.1 of the License, or (at your option) any later version.
   24.12 -
   24.13 -    This library is distributed in the hope that it will be useful,
   24.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   24.16 -    Lesser General Public License for more details.
   24.17 -
   24.18 -    You should have received a copy of the GNU Lesser General Public
   24.19 -    License along with this library; if not, write to the Free Software
   24.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   24.21 -
   24.22 -    Sam Lantinga
   24.23 -    slouken@libsdl.org
   24.24 -*/
   24.25 -#include "SDL_config.h"
   24.26 -
   24.27 -/* StormMesa implementation of SDL OpenGL support */
   24.28 -
   24.29 -#include "SDL_cgxgl_c.h"
   24.30 -#include "SDL_cgxvideo.h"
   24.31 -
   24.32 -#if SDL_VIDEO_OPENGL
   24.33 -AmigaMesaContext glcont=NULL;
   24.34 -#endif
   24.35 -
   24.36 -/* Init OpenGL */
   24.37 -int CGX_GL_Init(_THIS)
   24.38 -{
   24.39 -#if SDL_VIDEO_OPENGL
   24.40 -   int i = 0;
   24.41 -	struct TagItem attributes [ 14 ]; /* 14 should be more than enough :) */
   24.42 -   struct Window *win = (struct Window *)SDL_Window;
   24.43 -
   24.44 -	// default config. Always used...
   24.45 -	attributes[i].ti_Tag = AMA_Window;	attributes[i++].ti_Data = (unsigned long)win;
   24.46 -	attributes[i].ti_Tag = AMA_Left;		attributes[i++].ti_Data = 0;
   24.47 -	attributes[i].ti_Tag = AMA_Bottom;	attributes[i++].ti_Data = 0;
   24.48 -	attributes[i].ti_Tag = AMA_Width;	attributes[i++].ti_Data = win->Width-win->BorderLeft-win->BorderRight;
   24.49 -	attributes[i].ti_Tag = AMA_Height;	attributes[i++].ti_Data = win->Height-win->BorderBottom-win->BorderTop;
   24.50 -	attributes[i].ti_Tag = AMA_DirectRender; attributes[i++].ti_Data = GL_TRUE;
   24.51 -
   24.52 -	// double buffer ?
   24.53 -	attributes[i].ti_Tag = AMA_DoubleBuf;
   24.54 -	if ( this->gl_config.double_buffer ) {
   24.55 -		attributes[i++].ti_Data = GL_TRUE;
   24.56 -	}
   24.57 -	else {
   24.58 -		attributes[i++].ti_Data = GL_FALSE;
   24.59 -	}
   24.60 -	// RGB(A) Mode ?
   24.61 -	attributes[i].ti_Tag = AMA_RGBMode;
   24.62 -	if ( this->gl_config.red_size   != 0 &&
   24.63 -	     this->gl_config.blue_size  != 0 &&
   24.64 -	     this->gl_config.green_size != 0 ) {
   24.65 -		attributes[i++].ti_Data = GL_TRUE;
   24.66 -	}
   24.67 -	else {
   24.68 -		attributes[i++].ti_Data = GL_FALSE;
   24.69 -	}
   24.70 -	// no depth buffer ?
   24.71 -	if ( this->gl_config.depth_size == 0 ) {
   24.72 -		attributes[i].ti_Tag = AMA_NoDepth;
   24.73 -		attributes[i++].ti_Data = GL_TRUE;
   24.74 -	}
   24.75 -	// no stencil buffer ?
   24.76 -	if ( this->gl_config.stencil_size == 0 ) {
   24.77 -		attributes[i].ti_Tag = AMA_NoStencil;
   24.78 -		attributes[i++].ti_Data = GL_TRUE;
   24.79 -	}
   24.80 -	// no accum buffer ?
   24.81 -	if ( this->gl_config.accum_red_size   != 0 &&
   24.82 -	     this->gl_config.accum_blue_size  != 0 &&
   24.83 -	     this->gl_config.accum_green_size != 0 ) {
   24.84 -		attributes[i].ti_Tag = AMA_NoAccum;
   24.85 -		attributes[i++].ti_Data = GL_TRUE;
   24.86 -	}
   24.87 -	// done...
   24.88 -	attributes[i].ti_Tag	= TAG_DONE;
   24.89 -
   24.90 -	glcont = AmigaMesaCreateContext(attributes);
   24.91 -	if ( glcont == NULL ) {
   24.92 -		SDL_SetError("Couldn't create OpenGL context");
   24.93 -		return(-1);
   24.94 -	}
   24.95 -	this->gl_data->gl_active = 1;
   24.96 -	this->gl_config.driver_loaded = 1;
   24.97 -
   24.98 -	return(0);
   24.99 -#else
  24.100 -	SDL_SetError("OpenGL support not configured");
  24.101 -	return(-1);
  24.102 -#endif
  24.103 -}
  24.104 -
  24.105 -/* Quit OpenGL */
  24.106 -void CGX_GL_Quit(_THIS)
  24.107 -{
  24.108 -#if SDL_VIDEO_OPENGL
  24.109 -	if ( glcont != NULL ) {
  24.110 -		AmigaMesaDestroyContext(glcont);
  24.111 -		glcont = NULL;
  24.112 -		this->gl_data->gl_active = 0;
  24.113 -		this->gl_config.driver_loaded = 0;
  24.114 -	}
  24.115 -#endif
  24.116 -}
  24.117 -
  24.118 -/* Attach context to another window */
  24.119 -int CGX_GL_Update(_THIS)
  24.120 -{
  24.121 -#if SDL_VIDEO_OPENGL
  24.122 -	struct TagItem tags[2];
  24.123 -	struct Window *win = (struct Window*)SDL_Window;
  24.124 -	if(glcont == NULL) {
  24.125 -		return -1; //should never happen
  24.126 -	}
  24.127 -	tags[0].ti_Tag = AMA_Window;
  24.128 -	tags[0].ti_Data = (unsigned long)win;
  24.129 -	tags[1].ti_Tag = TAG_DONE;
  24.130 -	AmigaMesaSetRast(glcont, tags);
  24.131 -
  24.132 -	return 0;
  24.133 -#else
  24.134 -	SDL_SetError("OpenGL support not configured");
  24.135 -	return -1;
  24.136 -#endif
  24.137 -}
  24.138 -
  24.139 -#if SDL_VIDEO_OPENGL
  24.140 -
  24.141 -/* Make the current context active */
  24.142 -int CGX_GL_MakeCurrent(_THIS)
  24.143 -{
  24.144 -	if(glcont == NULL)
  24.145 -		return -1;
  24.146 -
  24.147 -	AmigaMesaMakeCurrent(glcont, glcont->buffer);
  24.148 -	return 0;
  24.149 -}
  24.150 -
  24.151 -void CGX_GL_SwapBuffers(_THIS)
  24.152 -{
  24.153 -	AmigaMesaSwapBuffers(glcont);
  24.154 -}
  24.155 -
  24.156 -int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) {
  24.157 -	GLenum mesa_attrib;
  24.158 -
  24.159 -	switch(attrib) {
  24.160 -		case SDL_GL_RED_SIZE:
  24.161 -			mesa_attrib = GL_RED_BITS;
  24.162 -			break;
  24.163 -		case SDL_GL_GREEN_SIZE:
  24.164 -			mesa_attrib = GL_GREEN_BITS;
  24.165 -			break;
  24.166 -		case SDL_GL_BLUE_SIZE:
  24.167 -			mesa_attrib = GL_BLUE_BITS;
  24.168 -			break;
  24.169 -		case SDL_GL_ALPHA_SIZE:
  24.170 -			mesa_attrib = GL_ALPHA_BITS;
  24.171 -			break;
  24.172 -		case SDL_GL_DOUBLEBUFFER:
  24.173 -			mesa_attrib = GL_DOUBLEBUFFER;
  24.174 -			break;
  24.175 -		case SDL_GL_DEPTH_SIZE:
  24.176 -			mesa_attrib = GL_DEPTH_BITS;
  24.177 -			break;
  24.178 -		case SDL_GL_STENCIL_SIZE:
  24.179 -			mesa_attrib = GL_STENCIL_BITS;
  24.180 -			break;
  24.181 -		case SDL_GL_ACCUM_RED_SIZE:
  24.182 -			mesa_attrib = GL_ACCUM_RED_BITS;
  24.183 -			break;
  24.184 -		case SDL_GL_ACCUM_GREEN_SIZE:
  24.185 -			mesa_attrib = GL_ACCUM_GREEN_BITS;
  24.186 -			break;
  24.187 -		case SDL_GL_ACCUM_BLUE_SIZE:
  24.188 -			mesa_attrib = GL_ACCUM_BLUE_BITS;
  24.189 -			break;
  24.190 -		case SDL_GL_ACCUM_ALPHA_SIZE:
  24.191 -			mesa_attrib = GL_ACCUM_ALPHA_BITS;
  24.192 -			break;
  24.193 -		default :
  24.194 -			return -1;
  24.195 -	}
  24.196 -
  24.197 -	AmigaMesaGetConfig(glcont->visual, mesa_attrib, value);
  24.198 -	return 0;
  24.199 -}
  24.200 -
  24.201 -void *CGX_GL_GetProcAddress(_THIS, const char *proc) {
  24.202 -	void *func = NULL;
  24.203 -	func = AmiGetGLProc(proc);
  24.204 -	return func;
  24.205 -}
  24.206 -
  24.207 -int CGX_GL_LoadLibrary(_THIS, const char *path) {
  24.208 -	/* Library is always open */
  24.209 -	this->gl_config.driver_loaded = 1;
  24.210 -
  24.211 -	return 0;
  24.212 -}
  24.213 -
  24.214 -#endif /* SDL_VIDEO_OPENGL */
  24.215 -
    25.1 --- a/src/video/cybergfx/SDL_cgxgl_c.h	Sun Oct 29 03:44:25 2006 +0000
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,51 +0,0 @@
    25.4 -/*
    25.5 -    SDL - Simple DirectMedia Layer
    25.6 -    Copyright (C) 1997-2006 Sam Lantinga
    25.7 -
    25.8 -    This library is free software; you can redistribute it and/or
    25.9 -    modify it under the terms of the GNU Lesser General Public
   25.10 -    License as published by the Free Software Foundation; either
   25.11 -    version 2.1 of the License, or (at your option) any later version.
   25.12 -
   25.13 -    This library is distributed in the hope that it will be useful,
   25.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   25.16 -    Lesser General Public License for more details.
   25.17 -
   25.18 -    You should have received a copy of the GNU Lesser General Public
   25.19 -    License along with this library; if not, write to the Free Software
   25.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   25.21 -
   25.22 -    Sam Lantinga
   25.23 -    slouken@libsdl.org
   25.24 -*/
   25.25 -#include "SDL_config.h"
   25.26 -
   25.27 -/* StormMesa implementation of SDL OpenGL support */
   25.28 -
   25.29 -#include "../SDL_sysvideo.h"
   25.30 -
   25.31 -#define _THIS   SDL_VideoDevice *_this
   25.32 -
   25.33 -#if SDL_VIDEO_OPENGL
   25.34 -#include <GL/Amigamesa.h>
   25.35 -extern void *AmiGetGLProc(const char *proc);
   25.36 -#endif /* SDL_VIDEO_OPENGL */
   25.37 -
   25.38 -struct SDL_PrivateGLData {
   25.39 -	int gl_active;
   25.40 -};
   25.41 -
   25.42 -/* OpenGL functions */
   25.43 -extern int CGX_GL_Init(_THIS);
   25.44 -extern void CGX_GL_Quit(_THIS);
   25.45 -extern int CGX_GL_Update(_THIS);
   25.46 -#if SDL_VIDEO_OPENGL
   25.47 -extern int CGX_GL_MakeCurrent(_THIS);
   25.48 -extern int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
   25.49 -extern void CGX_GL_SwapBuffers(_THIS);
   25.50 -extern void *CGX_GL_GetProcAddress(_THIS, const char *proc);
   25.51 -extern int CGX_GL_LoadLibrary(_THIS, const char *path);
   25.52 -#endif
   25.53 -
   25.54 -#undef _THIS
    26.1 --- a/src/video/cybergfx/SDL_cgximage.c	Sun Oct 29 03:44:25 2006 +0000
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,906 +0,0 @@
    26.4 -/*
    26.5 -    SDL - Simple DirectMedia Layer
    26.6 -    Copyright (C) 1997-2006 Sam Lantinga
    26.7 -
    26.8 -    This library is free software; you can redistribute it and/or
    26.9 -    modify it under the terms of the GNU Lesser General Public
   26.10 -    License as published by the Free Software Foundation; either
   26.11 -    version 2.1 of the License, or (at your option) any later version.
   26.12 -
   26.13 -    This library is distributed in the hope that it will be useful,
   26.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   26.16 -    Lesser General Public License for more details.
   26.17 -
   26.18 -    You should have received a copy of the GNU Lesser General Public
   26.19 -    License along with this library; if not, write to the Free Software
   26.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   26.21 -
   26.22 -    Sam Lantinga
   26.23 -    slouken@libsdl.org
   26.24 -*/
   26.25 -#include "SDL_config.h"
   26.26 -
   26.27 -#include "SDL_endian.h"
   26.28 -#include "SDL_cgximage_c.h"
   26.29 -
   26.30 -#ifdef HAVE_KSTAT
   26.31 -#include <kstat.h>
   26.32 -#endif
   26.33 -
   26.34 -#ifdef USE_CGX_WRITELUTPIXEL
   26.35 -#if defined(__SASC) || defined(__PPC__)
   26.36 -	#define WLUT WriteLUTPixelArray
   26.37 -#else
   26.38 -void WLUT(APTR a,UWORD b,UWORD c,UWORD d,struct RastPort *e,APTR f,UWORD g,UWORD h,UWORD i,UWORD l,UBYTE m)
   26.39 -{	WriteLUTPixelArray(a,b,c,d,e,f,g,h,i,l,m); }
   26.40 -#endif
   26.41 -
   26.42 -#endif
   26.43 -
   26.44 -/* Various screen update functions available */
   26.45 -static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
   26.46 -static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect *rects);
   26.47 -
   26.48 -BOOL SafeDisp=TRUE,SafeChange=TRUE;
   26.49 -struct MsgPort *safeport=NULL,*dispport=NULL;
   26.50 -ULONG safe_sigbit,disp_sigbit;
   26.51 -int use_picasso96=1;
   26.52 -
   26.53 -int CGX_SetupImage(_THIS, SDL_Surface *screen)
   26.54 -{
   26.55 -	SDL_Ximage=NULL;
   26.56 -
   26.57 -	if(screen->flags&SDL_HWSURFACE) {
   26.58 -		ULONG pitch;
   26.59 -
   26.60 -		if(!screen->hwdata) {
   26.61 -			if(!(screen->hwdata=SDL_malloc(sizeof(struct private_hwdata))))
   26.62 -				return -1;
   26.63 -
   26.64 -			D(bug("Creating system accel struct\n"));
   26.65 -		}
   26.66 -		screen->hwdata->lock=NULL;
   26.67 -		screen->hwdata->allocated=0;
   26.68 -		screen->hwdata->mask=NULL;
   26.69 -		screen->hwdata->bmap=SDL_RastPort->BitMap;
   26.70 -		screen->hwdata->videodata=this;
   26.71 -
   26.72 -		if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap,
   26.73 -				LBMI_BASEADDRESS,(ULONG)&screen->pixels,
   26.74 -				LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) {
   26.75 -			SDL_free(screen->hwdata);
   26.76 -			screen->hwdata=NULL;
   26.77 -			return -1;
   26.78 -		}
   26.79 -		else {
   26.80 -			UnLockBitMap(screen->hwdata->lock);
   26.81 -			screen->hwdata->lock=NULL;
   26.82 -		}
   26.83 -
   26.84 -		screen->pitch=pitch;
   26.85 -
   26.86 -		this->UpdateRects = CGX_FakeUpdate;
   26.87 -
   26.88 -		D(bug("Accel video image configured (%lx, pitch %ld).\n",screen->pixels,screen->pitch));
   26.89 -		return 0;
   26.90 -	}
   26.91 -
   26.92 -	screen->pixels = SDL_malloc(screen->h*screen->pitch);
   26.93 -
   26.94 -	if ( screen->pixels == NULL ) {
   26.95 -		SDL_OutOfMemory();
   26.96 -		return(-1);
   26.97 -	}
   26.98 -
   26.99 -	SDL_Ximage=screen->pixels;
  26.100 -
  26.101 -	if ( SDL_Ximage == NULL ) {
  26.102 -		SDL_SetError("Couldn't create XImage");
  26.103 -		return(-1);
  26.104 -	}
  26.105 -
  26.106 -	this->UpdateRects = CGX_NormalUpdate;
  26.107 -
  26.108 -	return(0);
  26.109 -}
  26.110 -
  26.111 -void CGX_DestroyImage(_THIS, SDL_Surface *screen)
  26.112 -{
  26.113 -	if ( SDL_Ximage ) {
  26.114 -		SDL_free(SDL_Ximage);
  26.115 -		SDL_Ximage = NULL;
  26.116 -	}
  26.117 -	if ( screen ) {
  26.118 -		screen->pixels = NULL;
  26.119 -
  26.120 -		if(screen->hwdata) {
  26.121 -			SDL_free(screen->hwdata);
  26.122 -			screen->hwdata=NULL;
  26.123 -		}
  26.124 -	}
  26.125 -}
  26.126 -
  26.127 -/* This is a hack to see whether this system has more than 1 CPU */
  26.128 -static int num_CPU(void)
  26.129 -{
  26.130 -	return 1;
  26.131 -}
  26.132 -
  26.133 -int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
  26.134 -{
  26.135 -	int retval;
  26.136 -
  26.137 -	D(bug("Calling ResizeImage()\n"));
  26.138 -
  26.139 -	CGX_DestroyImage(this, screen);
  26.140 -
  26.141 -	if ( flags & SDL_OPENGL ) {  /* No image when using GL */
  26.142 -        	retval = 0;
  26.143 -	} else {
  26.144 -		retval = CGX_SetupImage(this, screen);
  26.145 -		/* We support asynchronous blitting on the display */
  26.146 -		if ( flags & SDL_ASYNCBLIT ) {
  26.147 -			if ( num_CPU() > 1 ) {
  26.148 -				screen->flags |= SDL_ASYNCBLIT;
  26.149 -			}
  26.150 -		}
  26.151 -	}
  26.152 -	return(retval);
  26.153 -}
  26.154 -
  26.155 -int CGX_AllocHWSurface(_THIS, SDL_Surface *surface)
  26.156 -{
  26.157 -	D(bug("Alloc HW surface...%ld x %ld x %ld!\n",surface->w,surface->h,this->hidden->depth));
  26.158 -
  26.159 -	if(surface==SDL_VideoSurface)
  26.160 -	{
  26.161 -		D(bug("Allocation skipped, it's system one!\n"));
  26.162 -		return 0;
  26.163 -	}
  26.164 -
  26.165 -	if(!surface->hwdata)
  26.166 -	{
  26.167 -		if(!(surface->hwdata=SDL_malloc(sizeof(struct private_hwdata))))
  26.168 -			return -1;
  26.169 -	}
  26.170 -
  26.171 -	surface->hwdata->mask=NULL;
  26.172 -	surface->hwdata->lock=NULL;
  26.173 -	surface->hwdata->videodata=this;
  26.174 -	surface->hwdata->allocated=0;
  26.175 -
  26.176 -	if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap))
  26.177 -	{
  26.178 -		surface->hwdata->allocated=1;
  26.179 -		surface->flags|=SDL_HWSURFACE;
  26.180 -		D(bug("...OK\n"));
  26.181 -		return 0;
  26.182 -	}
  26.183 -	else
  26.184 -	{
  26.185 -		SDL_free(surface->hwdata);
  26.186 -		surface->hwdata=NULL;
  26.187 -	}
  26.188 -
  26.189 -	return(-1);
  26.190 -}
  26.191 -void CGX_FreeHWSurface(_THIS, SDL_Surface *surface)
  26.192 -{
  26.193 -	if(surface && surface!=SDL_VideoSurface && surface->hwdata)
  26.194 -	{
  26.195 -		D(bug("Free hw surface.\n"));
  26.196 -
  26.197 -		if(surface->hwdata->mask)
  26.198 -			SDL_free(surface->hwdata->mask);
  26.199 -
  26.200 -		if(surface->hwdata->bmap&&surface->hwdata->allocated)
  26.201 -			FreeBitMap(surface->hwdata->bmap);
  26.202 -
  26.203 -		SDL_free(surface->hwdata);
  26.204 -		surface->hwdata=NULL;
  26.205 -		surface->pixels=NULL;
  26.206 -		D(bug("end of free hw surface\n"));
  26.207 -	}
  26.208 -	return;
  26.209 -}
  26.210 -
  26.211 -int CGX_LockHWSurface(_THIS, SDL_Surface *surface)
  26.212 -{
  26.213 -	if (surface->hwdata)
  26.214 -	{
  26.215 -//		D(bug("Locking a bitmap...\n"));
  26.216 -		if(!surface->hwdata->lock)
  26.217 -		{	
  26.218 -			Uint32 pitch;
  26.219 -
  26.220 -			if(!(surface->hwdata->lock=LockBitMapTags(surface->hwdata->bmap,
  26.221 -					LBMI_BASEADDRESS,(ULONG)&surface->pixels,
  26.222 -					LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE)))
  26.223 -				return -1;
  26.224 -
  26.225 -// surface->pitch e' a 16bit!
  26.226 -
  26.227 -			surface->pitch=pitch;
  26.228 -
  26.229 -			if(!currently_fullscreen&&surface==SDL_VideoSurface)
  26.230 -				surface->pixels=((char *)surface->pixels)+(surface->pitch*(SDL_Window->BorderTop+SDL_Window->TopEdge)+
  26.231 -					surface->format->BytesPerPixel*(SDL_Window->BorderLeft+SDL_Window->LeftEdge));
  26.232 -		}
  26.233 -		D(else bug("Already locked!!!\n"));
  26.234 -	}
  26.235 -	return(0);
  26.236 -}
  26.237 -
  26.238 -void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface)
  26.239 -{
  26.240 -	if(surface->hwdata && surface->hwdata->lock)
  26.241 -	{
  26.242 -		UnLockBitMap(surface->hwdata->lock);
  26.243 -		surface->hwdata->lock=NULL;
  26.244 -//		surface->pixels=NULL;
  26.245 -	}
  26.246 -}
  26.247 -
  26.248 -int CGX_FlipHWSurface(_THIS, SDL_Surface *surface)
  26.249 -{
  26.250 -	static int current=0;
  26.251 -
  26.252 -	if(this->hidden->dbuffer)
  26.253 -	{
  26.254 -		if(!SafeChange)
  26.255 -		{
  26.256 -			Wait(disp_sigbit);
  26.257 -// Non faccio nulla, vuoto solo la porta
  26.258 -			while(GetMsg(dispport)!=NULL) 
  26.259 -				;
  26.260 -			SafeChange=TRUE;
  26.261 -		}
  26.262 -
  26.263 -		if(ChangeScreenBuffer(SDL_Display,this->hidden->SB[current^1]))
  26.264 -		{
  26.265 -			surface->hwdata->bmap=SDL_RastPort->BitMap=this->hidden->SB[current]->sb_BitMap;
  26.266 -			SafeChange=FALSE;
  26.267 -			SafeDisp=FALSE;
  26.268 -			current^=1;
  26.269 -		}
  26.270 -
  26.271 -		if(!SafeDisp)
  26.272 -		{
  26.273 -			Wait(safe_sigbit);
  26.274 -			while(GetMsg(safeport)!=NULL) 
  26.275 -				;
  26.276 -			SafeDisp=TRUE;
  26.277 -		}
  26.278 -
  26.279 -	}
  26.280 -	return(0);
  26.281 -}
  26.282 -
  26.283 -/* Byte-swap the pixels in the display image */
  26.284 -static void CGX_SwapAllPixels(SDL_Surface *screen)
  26.285 -{
  26.286 -	int x, y;
  26.287 -
  26.288 -	switch (screen->format->BytesPerPixel) {
  26.289 -	    case 2: {
  26.290 -		Uint16 *spot;
  26.291 -		for ( y=0; y<screen->h; ++y ) {
  26.292 -			spot = (Uint16 *) ((Uint8 *)screen->pixels +
  26.293 -						y * screen->pitch);
  26.294 -			for ( x=0; x<screen->w; ++x, ++spot ) {
  26.295 -				*spot = SDL_Swap16(*spot);
  26.296 -			}
  26.297 -		}
  26.298 -	    }
  26.299 -	    break;
  26.300 -
  26.301 -	    case 4: {
  26.302 -		Uint32 *spot;
  26.303 -		for ( y=0; y<screen->h; ++y ) {
  26.304 -			spot = (Uint32 *) ((Uint8 *)screen->pixels +
  26.305 -						y * screen->pitch);
  26.306 -			for ( x=0; x<screen->w; ++x, ++spot ) {
  26.307 -				*spot = SDL_Swap32(*spot);
  26.308 -			}
  26.309 -		}
  26.310 -	    }
  26.311 -	    break;
  26.312 -
  26.313 -	    default:
  26.314 -		/* should never get here */
  26.315 -		break;
  26.316 -	}
  26.317 -}
  26.318 -static void CGX_SwapPixels(SDL_Surface *screen, int numrects, SDL_Rect *rects)
  26.319 -{
  26.320 -	int i;
  26.321 -	int x, minx, maxx;
  26.322 -	int y, miny, maxy;
  26.323 -
  26.324 -	switch (screen->format->BytesPerPixel) {
  26.325 -	    case 2: {
  26.326 -		Uint16 *spot;
  26.327 -		for ( i=0; i<numrects; ++i ) {
  26.328 -			minx = rects[i].x;
  26.329 -			maxx = rects[i].x+rects[i].w;
  26.330 -			miny = rects[i].y;
  26.331 -			maxy = rects[i].y+rects[i].h;
  26.332 -			for ( y=miny; y<maxy; ++y ) {
  26.333 -				spot = (Uint16 *) ((Uint8 *)screen->pixels +
  26.334 -						y * screen->pitch + minx * 2);
  26.335 -				for ( x=minx; x<maxx; ++x, ++spot ) {
  26.336 -					*spot = SDL_Swap16(*spot);
  26.337 -				}
  26.338 -			}
  26.339 -		}
  26.340 -	    }
  26.341 -	    break;
  26.342 -
  26.343 -	    case 4: {
  26.344 -		Uint32 *spot;
  26.345 -		for ( i=0; i<numrects; ++i ) {
  26.346 -			minx = rects[i].x;
  26.347 -			maxx = rects[i].x+rects[i].w;
  26.348 -			miny = rects[i].y;
  26.349 -			maxy = rects[i].y+rects[i].h;
  26.350 -			for ( y=miny; y<maxy; ++y ) {
  26.351 -				spot = (Uint32 *) ((Uint8 *)screen->pixels +
  26.352 -						y * screen->pitch + minx * 4);
  26.353 -				for ( x=minx; x<maxx; ++x, ++spot ) {
  26.354 -					*spot = SDL_Swap32(*spot);
  26.355 -				}
  26.356 -			}
  26.357 -		}
  26.358 -	    }
  26.359 -	    break;
  26.360 -
  26.361 -	    default:
  26.362 -		/* should never get here */
  26.363 -		break;
  26.364 -	}
  26.365 -}
  26.366 -
  26.367 -#ifdef __SASC
  26.368 -
  26.369 -#define USE_WPA WritePixelArray
  26.370 -#else
  26.371 -
  26.372 -void USE_WPA(char *a,int b,int c,int d, struct RastPort *e,int f,int g, int h, int i, Uint32 l)
  26.373 -{
  26.374 -		WritePixelArray(a,b,c,d,e,f,g,h,i,l);
  26.375 -}
  26.376 -
  26.377 -#endif
  26.378 -
  26.379 -static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect *rects)
  26.380 -{
  26.381 -}
  26.382 -
  26.383 -static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
  26.384 -{
  26.385 -	int i,format,customroutine=0;
  26.386 -#ifndef USE_CGX_WRITELUTPIXEL
  26.387 -	int bpp;
  26.388 -#endif
  26.389 -	if(this->hidden->same_format && !use_picasso96)
  26.390 -	{
  26.391 -		format=RECTFMT_RAW;
  26.392 -	}
  26.393 -	else switch(this->screen->format->BytesPerPixel)
  26.394 -	{
  26.395 -		case 4:
  26.396 -			format=RECTFMT_RGBA;
  26.397 -			break;
  26.398 -		case 3:
  26.399 -			format=RECTFMT_RGB;
  26.400 -			break;
  26.401 -		case 2:
  26.402 -			customroutine=1;
  26.403 -			break;
  26.404 -		case 1:
  26.405 -//			D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
  26.406 -			if(this->hidden->depth>8)
  26.407 -			{
  26.408 -#ifndef USE_CGX_WRITELUTPIXEL
  26.409 -				if(this->hidden->depth>32)
  26.410 -					customroutine=4;
  26.411 -				else if(this->hidden->depth>16)
  26.412 -				{
  26.413 -					bpp=this->hidden->BytesPerPixel; // That one is the only one that needs bpp
  26.414 -					customroutine=2; // The slow one!
  26.415 -				}
  26.416 -				else
  26.417 -					customroutine=3;
  26.418 -#else
  26.419 -
  26.420 -				customroutine=2;
  26.421 -#endif
  26.422 -				
  26.423 -//				format=RECTFMT_LUT8;   Vecchia funzione x usare la WritePixelArray.
  26.424 -			}
  26.425 -			else
  26.426 -				customroutine=1;
  26.427 -			break;
  26.428 -		default:
  26.429 -			D(bug("Unable to blit this surface!\n"));	
  26.430 -			return;
  26.431 -	}
  26.432 -
  26.433 -	/* Check for endian-swapped X server, swap if necessary (VERY slow!) */
  26.434 -	if ( swap_pixels &&
  26.435 -	     ((this->screen->format->BytesPerPixel%2) == 0) ) {
  26.436 -		D(bug("Software Swapping! SLOOOW!\n"));
  26.437 -		CGX_SwapPixels(this->screen, numrects, rects);
  26.438 -		for ( i=0; i<numrects; ++i ) {
  26.439 -			if ( ! rects[i].w ) { /* Clipped? */
  26.440 -				continue;
  26.441 -			}
  26.442 -			USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch,
  26.443 -					SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y,
  26.444 -					rects[i].w,rects[i].h,format);
  26.445 -		}
  26.446 -		CGX_SwapPixels(this->screen, numrects, rects);
  26.447 -	}
  26.448 -	else if (customroutine==2)
  26.449 -	{
  26.450 -#ifdef USE_CGX_WRITELUTPIXEL
  26.451 -		for ( i=0; i<numrects; ++i ) {
  26.452 -			if ( ! rects[i].w ) { /* Clipped? */
  26.453 -				continue;
  26.454 -			}
  26.455 -
  26.456 -			WLUT(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch,
  26.457 -					SDL_RastPort,SDL_XPixels,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y,
  26.458 -					rects[i].w,rects[i].h,CTABFMT_XRGB8);
  26.459 -		}
  26.460 -#else
  26.461 -		unsigned char *bm_address;
  26.462 -		Uint32	destpitch;
  26.463 -		APTR handle;
  26.464 -
  26.465 -		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address,
  26.466 -								LBMI_BYTESPERROW,&destpitch,TAG_DONE))
  26.467 -		{
  26.468 -			int srcwidth;
  26.469 -			unsigned char *destbase;
  26.470 -			register int j,k,t;
  26.471 -			register unsigned char *mask,*dst;
  26.472 -			register unsigned char *src,*dest;
  26.473 -
  26.474 -// Aggiungo il bordo della finestra se sono fullscreen.
  26.475 -			if(currently_fullscreen)
  26.476 -				destbase=bm_address;
  26.477 -			else
  26.478 -				destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
  26.479 -
  26.480 -			for ( i=0; i<numrects; ++i ) 
  26.481 -			{
  26.482 -				srcwidth=rects[i].w;
  26.483 -
  26.484 -				if ( !srcwidth ) { /* Clipped? */
  26.485 -					continue;
  26.486 -				}
  26.487 -
  26.488 -				dest=destbase+rects[i].x*this->hidden->BytesPerPixel;
  26.489 -				dest+=(rects[i].y*destpitch);
  26.490 -				src=((char *)(this->screen->pixels))+rects[i].x;
  26.491 -				src+=(rects[i].y*this->screen->pitch);
  26.492 -				
  26.493 -				for(j=rects[i].h;j;--j)
  26.494 -				{
  26.495 -					dst=dest;
  26.496 -// SLOW routine, used for 8->24 bit mapping
  26.497 -					for(k=0;k<srcwidth;k++)
  26.498 -					{
  26.499 -						mask=(unsigned char *)(&SDL_XPixels[src[k]]);
  26.500 -						for(t=0;t<bpp;t++)
  26.501 -						{
  26.502 -							dst[t]=mask[t];
  26.503 -						}
  26.504 -						dst+=bpp;
  26.505 -					}
  26.506 -					src+=this->screen->pitch;
  26.507 -					dest+=destpitch;
  26.508 -				}
  26.509 -			}
  26.510 -			UnLockBitMap(handle);
  26.511 -		}
  26.512 -	}
  26.513 -	else if (customroutine==3)
  26.514 -	{
  26.515 -		unsigned char *bm_address;
  26.516 -		Uint32	destpitch;
  26.517 -		APTR handle;
  26.518 -
  26.519 -		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address,
  26.520 -								LBMI_BYTESPERROW,&destpitch,TAG_DONE))
  26.521 -		{
  26.522 -			int srcwidth;
  26.523 -			unsigned char *destbase;
  26.524 -			register int j,k;
  26.525 -			register unsigned char *src,*dest;
  26.526 -			register Uint16 *destl,*srcl;
  26.527 -
  26.528 -			if(currently_fullscreen)
  26.529 -				destbase=bm_address;
  26.530 -			else
  26.531 -				destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
  26.532 -
  26.533 -			for ( i=0; i<numrects; ++i ) 
  26.534 -			{
  26.535 -				srcwidth=rects[i].w;
  26.536 -
  26.537 -				if ( !srcwidth ) { /* Clipped? */
  26.538 -					continue;
  26.539 -				}
  26.540 -
  26.541 -				dest=destbase+rects[i].x*this->hidden->BytesPerPixel;
  26.542 -				dest+=(rects[i].y*destpitch);
  26.543 -				src=((char *)(this->screen->pixels))+rects[i].x;
  26.544 -				src+=(rects[i].y*this->screen->pitch);
  26.545 -				
  26.546 -// This is the fast, well not too slow, remapping code for 16bit displays
  26.547 -
  26.548 -				for(j=rects[i].h;j;--j)
  26.549 -				{
  26.550 -					destl=(Uint16 *)dest;
  26.551 -
  26.552 -					for(k=0;k<srcwidth;k++)
  26.553 -					{
  26.554 -						srcl=(Uint16 *)&SDL_XPixels[src[k]];
  26.555 -						*destl=*srcl;
  26.556 -						destl++;
  26.557 -					}
  26.558 -					src+=this->screen->pitch;
  26.559 -					dest+=destpitch;
  26.560 -				}
  26.561 -			}
  26.562 -			UnLockBitMap(handle);
  26.563 -		}
  26.564 -	}
  26.565 -	else if (customroutine==4)
  26.566 -	{
  26.567 -		unsigned char *bm_address;
  26.568 -		Uint32	destpitch;
  26.569 -		APTR handle;
  26.570 -
  26.571 -		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address,
  26.572 -								LBMI_BYTESPERROW,&destpitch,TAG_DONE))
  26.573 -		{
  26.574 -			int srcwidth;
  26.575 -			unsigned char *destbase;
  26.576 -			register int j,k;
  26.577 -			register unsigned char *src,*dest;
  26.578 -			register Uint32 *destl,*srcl;
  26.579 -
  26.580 -			if(currently_fullscreen)
  26.581 -				destbase=bm_address;
  26.582 -			else
  26.583 -				destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
  26.584 -
  26.585 -			for ( i=0; i<numrects; ++i ) 
  26.586 -			{
  26.587 -				srcwidth=rects[i].w;
  26.588 -
  26.589 -				if ( !srcwidth ) { /* Clipped? */
  26.590 -					continue;
  26.591 -				}
  26.592 -
  26.593 -				dest=destbase+rects[i].x*this->hidden->BytesPerPixel;
  26.594 -				dest+=(rects[i].y*destpitch);
  26.595 -				src=((char *)(this->screen->pixels))+rects[i].x;
  26.596 -				src+=(rects[i].y*this->screen->pitch);
  26.597 -				
  26.598 -// This is the fast, well not too slow, remapping code for 32bit displays
  26.599 -
  26.600 -				for(j=rects[i].h;j;--j)
  26.601 -				{
  26.602 -					destl=(Uint32 *)dest;
  26.603 -
  26.604 -					for(k=0;k<srcwidth;k++)
  26.605 -					{
  26.606 -						srcl=(Uint32 *)&SDL_XPixels[src[k]];
  26.607 -						*destl=*srcl;
  26.608 -						destl++;
  26.609 -					}
  26.610 -					src+=this->screen->pitch;
  26.611 -					dest+=destpitch;
  26.612 -				}
  26.613 -			}
  26.614 -			UnLockBitMap(handle);
  26.615 -		}
  26.616 -#endif
  26.617 -	}
  26.618 -	else if(customroutine)
  26.619 -	{
  26.620 -		unsigned char *bm_address;
  26.621 -		Uint32	destpitch;
  26.622 -		APTR handle;
  26.623 -
  26.624 -//		D(bug("Using customroutine!\n"));
  26.625 -
  26.626 -		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
  26.627 -								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
  26.628 -		{
  26.629 -			unsigned char *destbase;
  26.630 -			register int j,srcwidth;
  26.631 -			register unsigned char *src,*dest;
  26.632 -
  26.633 -// Aggiungo il bordo della finestra se sono fullscreen.
  26.634 -			if(currently_fullscreen)
  26.635 -				destbase=bm_address;
  26.636 -			else
  26.637 -				destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->screen->format->BytesPerPixel;
  26.638 -
  26.639 -			for ( i=0; i<numrects; ++i ) 
  26.640 -			{
  26.641 -				srcwidth=rects[i].w;
  26.642 -
  26.643 -				if ( !srcwidth ) { /* Clipped? */
  26.644 -					continue;
  26.645 -				}
  26.646 -
  26.647 -				dest=destbase+rects[i].x*this->screen->format->BytesPerPixel;
  26.648 -				dest+=(rects[i].y*destpitch);
  26.649 -				src=((char *)(this->screen->pixels))+rects[i].x*this->screen->format->BytesPerPixel;
  26.650 -				src+=(rects[i].y*this->screen->pitch);
  26.651 -				
  26.652 -				srcwidth*=this->screen->format->BytesPerPixel;
  26.653 -
  26.654 -//				D(bug("Rects: %ld,%ld %ld,%ld Src:%lx Dest:%lx\n",rects[i].x,rects[i].y,rects[i].w,rects[i].h,src,dest));
  26.655 -
  26.656 -				for(j=rects[i].h;j;--j)
  26.657 -				{
  26.658 -					SDL_memcpy(dest,src,srcwidth);
  26.659 -					src+=this->screen->pitch;
  26.660 -					dest+=destpitch;
  26.661 -				}
  26.662 -			}
  26.663 -			UnLockBitMap(handle);
  26.664 -//			D(bug("Rectblit addr: %lx pitch: %ld rects:%ld srcptr: %lx srcpitch: %ld\n",bm_address,destpitch,numrects,this->screen->pixels,this->screen->pitch));
  26.665 -		}
  26.666 -	}
  26.667 -	else
  26.668 -	{
  26.669 -		for ( i=0; i<numrects; ++i ) {
  26.670 -			if ( ! rects[i].w ) { /* Clipped? */
  26.671 -				continue;
  26.672 -			}
  26.673 -			USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch,
  26.674 -					SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y,
  26.675 -					rects[i].w,rects[i].h,format);
  26.676 -		}
  26.677 -	}
  26.678 -}
  26.679 -
  26.680 -void CGX_RefreshDisplay(_THIS)
  26.681 -{
  26.682 -	int format,customroutine=0;
  26.683 -#ifndef USE_CGX_WRITELUTPIXEL
  26.684 -	int bpp;
  26.685 -#endif
  26.686 -	/* Don't refresh a display that doesn't have an image (like GL) */
  26.687 -	if ( ! SDL_Ximage ) {
  26.688 -		return;
  26.689 -	}
  26.690 -
  26.691 -	if(this->hidden->same_format && !use_picasso96)
  26.692 -	{
  26.693 -		format=RECTFMT_RAW;
  26.694 -	}
  26.695 -	else switch(this->screen->format->BytesPerPixel)
  26.696 -	{
  26.697 -		case 4:
  26.698 -			format=RECTFMT_RGBA;
  26.699 -			break;
  26.700 -		case 3:
  26.701 -			format=RECTFMT_RGB;
  26.702 -			break;
  26.703 -		case 2:
  26.704 -			customroutine=1;
  26.705 -			break;
  26.706 -		case 1:
  26.707 -//			D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
  26.708 -			if(this->hidden->depth>8)
  26.709 -			{
  26.710 -#ifndef USE_CGX_WRITELUTPIXEL
  26.711 -				if(this->hidden->depth>32)
  26.712 -					customroutine=4;
  26.713 -				else if(this->hidden->depth>16)
  26.714 -				{
  26.715 -					bpp=this->hidden->BytesPerPixel; // That one is the only one that needs bpp
  26.716 -					customroutine=2; // The slow one!
  26.717 -				}
  26.718 -				else
  26.719 -					customroutine=3;
  26.720 -#else
  26.721 -
  26.722 -				customroutine=2;
  26.723 -#endif
  26.724 -//				format=RECTFMT_LUT8;
  26.725 -			}
  26.726 -			else
  26.727 -				customroutine=1;
  26.728 -			break;
  26.729 -
  26.730 -	}
  26.731 -
  26.732 -		/* Check for endian-swapped X server, swap if necessary */
  26.733 -	if ( swap_pixels &&
  26.734 -	     ((this->screen->format->BytesPerPixel%2) == 0) ) {
  26.735 -		CGX_SwapAllPixels(this->screen);
  26.736 -		USE_WPA(this->screen->pixels,0,0,this->screen->pitch,
  26.737 -				SDL_RastPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,
  26.738 -				this->screen->w,this->screen->h,format);
  26.739 -		CGX_SwapAllPixels(this->screen);
  26.740 -	}
  26.741 -	else if (customroutine==2)
  26.742 -	{
  26.743 -#ifdef USE_CGX_WRITELUTPIXEL
  26.744 -		WLUT(this->screen->pixels,0,0,this->screen->pitch,
  26.745 -					SDL_RastPort,SDL_XPixels,SDL_Window->BorderLeft,SDL_Window->BorderTop,
  26.746 -					this->screen->w,this->screen->h,CTABFMT_XRGB8);
  26.747 -#else
  26.748 -		unsigned char *bm_address;
  26.749 -		Uint32	destpitch;
  26.750 -		APTR handle;
  26.751 -
  26.752 -		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
  26.753 -								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
  26.754 -		{
  26.755 -			register int j,k,t;
  26.756 -			register unsigned char *mask,*dst;
  26.757 -			register unsigned char *src,*dest;
  26.758 -
  26.759 -// Aggiungo il bordo della finestra se sono fullscreen.
  26.760 -			if(!currently_fullscreen)
  26.761 -				dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
  26.762 -			else
  26.763 -				dest=bm_address;
  26.764 -
  26.765 -			src=this->screen->pixels;
  26.766 -				
  26.767 -			for(j=this->screen->h;j;--j)
  26.768 -			{
  26.769 -				dst=dest;
  26.770 -// SLOW routine, used for 8->24 bit mapping
  26.771 -				for(k=0;k<this->screen->w;k++)
  26.772 -				{
  26.773 -					mask=(unsigned char *)(&SDL_XPixels[src[k]]);
  26.774 -					for(t=0;t<bpp;t++)
  26.775 -					{
  26.776 -						dst[t]=mask[t];
  26.777 -					}
  26.778 -					dst+=bpp;
  26.779 -				}
  26.780 -				src+=this->screen->pitch;
  26.781 -				dest+=destpitch;
  26.782 -			}
  26.783 -			UnLockBitMap(handle);
  26.784 -		}
  26.785 -	}
  26.786 -	else if (customroutine==3)
  26.787 -	{
  26.788 -		unsigned char *bm_address;
  26.789 -		Uint32	destpitch;
  26.790 -		APTR handle;
  26.791 -
  26.792 -		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
  26.793 -								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
  26.794 -		{
  26.795 -			register int j,k;
  26.796 -			register unsigned char *src,*dest;
  26.797 -			register Uint16 *destl,*srcl;
  26.798 -
  26.799 -			if(!currently_fullscreen)
  26.800 -				dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
  26.801 -			else
  26.802 -				dest=bm_address;
  26.803 -
  26.804 -			src=this->screen->pixels;
  26.805 -				
  26.806 -// This is the fast, well not too slow, remapping code for 16bit displays
  26.807 -
  26.808 -			for(j=this->screen->h;j;--j)
  26.809 -			{
  26.810 -				destl=(Uint16 *)dest;
  26.811 -
  26.812 -				for(k=0;k<this->screen->w;k++)
  26.813 -				{
  26.814 -					srcl=(Uint16 *)&SDL_XPixels[src[k]];
  26.815 -					*destl=*srcl;
  26.816 -					destl++;
  26.817 -				}
  26.818 -				src+=this->screen->pitch;
  26.819 -				dest+=destpitch;
  26.820 -			}
  26.821 -			UnLockBitMap(handle);
  26.822 -		}
  26.823 -	}
  26.824 -	else if (customroutine==4)
  26.825 -	{
  26.826 -		unsigned char *bm_address;
  26.827 -		Uint32	destpitch;
  26.828 -		APTR handle;
  26.829 -
  26.830 -		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
  26.831 -								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
  26.832 -		{
  26.833 -			register int j,k;
  26.834 -			register unsigned char *src,*dest;
  26.835 -			register Uint32 *destl,*srcl;
  26.836 -
  26.837 -			if(!currently_fullscreen)
  26.838 -				dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
  26.839 -			else
  26.840 -				dest=bm_address;
  26.841 -
  26.842 -			src=this->screen->pixels;
  26.843 -				
  26.844 -// This is the fast, well not too slow, remapping code for 32bit displays
  26.845 -
  26.846 -			for(j=this->screen->h;j;--j)
  26.847 -			{
  26.848 -				destl=(Uint32 *)dest;
  26.849 -
  26.850 -				for(k=0;k<this->screen->w;k++)
  26.851 -				{
  26.852 -					srcl=(Uint32 *)&SDL_XPixels[src[k]];
  26.853 -					*destl=*srcl;
  26.854 -					destl++;
  26.855 -				}
  26.856 -				src+=this->screen->pitch;
  26.857 -				dest+=destpitch;
  26.858 -			}
  26.859 -			UnLockBitMap(handle);
  26.860 -		}
  26.861 -#endif
  26.862 -	}
  26.863 -	else if(customroutine)
  26.864 -	{
  26.865 -		unsigned char *bm_address;
  26.866 -		Uint32	destpitch;
  26.867 -		APTR handle;
  26.868 -
  26.869 -		if(handle=LockBitMapTags(SDL_RastPort->BitMap,
  26.870 -					LBMI_BASEADDRESS,(ULONG)&bm_address,
  26.871 -					LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
  26.872 -		{
  26.873 -			register int j;
  26.874 -			register unsigned char *src,*dest;
  26.875 -
  26.876 -			if(!currently_fullscreen)
  26.877 -				dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->screen->format->BytesPerPixel;
  26.878 -			else
  26.879 -				dest=bm_address;
  26.880 -
  26.881 -			src=this->screen->pixels;
  26.882 -				
  26.883 -//			D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch));
  26.884 -
  26.885 -			if(this->screen->pitch==destpitch)
  26.886 -			{
  26.887 -				SDL_memcpy(dest,src,this->screen->pitch*this->screen->h);
  26.888 -			}
  26.889 -			else
  26.890 -			{
  26.891 -				for(j=this->screen->h;j;--j)
  26.892 -				{
  26.893 -					SDL_memcpy(dest,src,this->screen->pitch);
  26.894 -					src+=this->screen->pitch;
  26.895 -					dest+=destpitch;
  26.896 -				}
  26.897 -			}
  26.898 -
  26.899 -			UnLockBitMap(handle);
  26.900 -		}
  26.901 -	}
  26.902 -	else
  26.903 -	{
  26.904 -		USE_WPA(this->screen->pixels,0,0,this->screen->pitch,
  26.905 -				SDL_RastPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,
  26.906 -				this->screen->w,this->screen->h,format);
  26.907 -	}
  26.908 -
  26.909 -}
    27.1 --- a/src/video/cybergfx/SDL_cgximage_c.h	Sun Oct 29 03:44:25 2006 +0000
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,36 +0,0 @@
    27.4 -/*
    27.5 -    SDL - Simple DirectMedia Layer
    27.6 -    Copyright (C) 1997-2006 Sam Lantinga
    27.7 -
    27.8 -    This library is free software; you can redistribute it and/or
    27.9 -    modify it under the terms of the GNU Lesser General Public
   27.10 -    License as published by the Free Software Foundation; either
   27.11 -    version 2.1 of the License, or (at your option) any later version.
   27.12 -
   27.13 -    This library is distributed in the hope that it will be useful,
   27.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   27.16 -    Lesser General Public License for more details.
   27.17 -
   27.18 -    You should have received a copy of the GNU Lesser General Public
   27.19 -    License along with this library; if not, write to the Free Software
   27.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   27.21 -
   27.22 -    Sam Lantinga
   27.23 -    slouken@libsdl.org
   27.24 -*/
   27.25 -#include "SDL_config.h"
   27.26 -
   27.27 -#include "SDL_cgxvideo.h"
   27.28 -
   27.29 -extern int CGX_SetupImage(_THIS, SDL_Surface *screen);
   27.30 -extern void CGX_DestroyImage(_THIS, SDL_Surface *screen);
   27.31 -extern int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags);
   27.32 -
   27.33 -extern int CGX_AllocHWSurface(_THIS, SDL_Surface *surface);
   27.34 -extern void CGX_FreeHWSurface(_THIS, SDL_Surface *surface);
   27.35 -extern int CGX_LockHWSurface(_THIS, SDL_Surface *surface);
   27.36 -extern void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface);
   27.37 -extern int CGX_FlipHWSurface(_THIS, SDL_Surface *surface);
   27.38 -
   27.39 -extern void CGX_RefreshDisplay(_THIS);
    28.1 --- a/src/video/cybergfx/SDL_cgxmodes.c	Sun Oct 29 03:44:25 2006 +0000
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,316 +0,0 @@
    28.4 -/*
    28.5 -    SDL - Simple DirectMedia Layer
    28.6 -    Copyright (C) 1997-2006 Sam Lantinga
    28.7 -
    28.8 -    This library is free software; you can redistribute it and/or
    28.9 -    modify it under the terms of the GNU Lesser General Public
   28.10 -    License as published by the Free Software Foundation; either
   28.11 -    version 2.1 of the License, or (at your option) any later version.
   28.12 -
   28.13 -    This library is distributed in the hope that it will be useful,
   28.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   28.16 -    Lesser General Public License for more details.
   28.17 -
   28.18 -    You should have received a copy of the GNU Lesser General Public
   28.19 -    License along with this library; if not, write to the Free Software
   28.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   28.21 -
   28.22 -    Sam Lantinga
   28.23 -    slouken@libsdl.org
   28.24 -*/
   28.25 -#include "SDL_config.h"
   28.26 -
   28.27 -/* Utilities for getting and setting the X display mode */
   28.28 -
   28.29 -#include "SDL_timer.h"
   28.30 -#include "SDL_events.h"
   28.31 -#include "../../events/SDL_events_c.h"
   28.32 -#include "SDL_cgxvideo.h"
   28.33 -#include "SDL_cgxwm_c.h"
   28.34 -#include "SDL_cgxmodes_c.h"
   28.35 -
   28.36 -#define CGX_DEBUG
   28.37 -
   28.38 -static void set_best_resolution(_THIS, int width, int height)
   28.39 -{
   28.40 -	Uint32 idok;
   28.41 -	int depth=8;
   28.42 -
   28.43 -	if(SDL_Display)
   28.44 -		depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
   28.45 -
   28.46 -	idok=BestCModeIDTags(CYBRBIDTG_NominalWidth,width,
   28.47 -				CYBRBIDTG_NominalHeight,height,
   28.48 -				CYBRBIDTG_Depth,depth,
   28.49 -				TAG_DONE);
   28.50 -
   28.51 -	if(idok!=INVALID_ID)
   28.52 -	{
   28.53 -		if(SDL_Display)
   28.54 -		{
   28.55 -			if(currently_fullscreen)
   28.56 -				CloseScreen(SDL_Display);
   28.57 -			else
   28.58 -				UnlockPubScreen(NULL,SDL_Display);
   28.59 -		}
   28.60 -		SDL_Display=GFX_Display=OpenScreenTags(NULL,SA_Width,width,SA_Height,height,
   28.61 -											SA_Depth,depth,SA_DisplayID,idok,
   28.62 -											SA_ShowTitle,FALSE,
   28.63 -											TAG_DONE);
   28.64 -	}
   28.65 -}
   28.66 -
   28.67 -static void get_real_resolution(_THIS, int* w, int* h)
   28.68 -{
   28.69 -    *w = /*SDL_Display->Width*/ SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight;
   28.70 -    *h = /*SDL_Display->Height*/ SDL_Window->Height-SDL_Window->BorderBottom-SDL_Window->BorderTop;
   28.71 -}
   28.72 -
   28.73 -static void move_cursor_to(_THIS, int x, int y)
   28.74 -{
   28.75 -/*    XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); */
   28.76 -
   28.77 -/* DA FARE! */
   28.78 -}
   28.79 -
   28.80 -static void add_visual(_THIS, int depth, int class)
   28.81 -{
   28.82 -	Uint32 tID;
   28.83 -
   28.84 -	tID=BestCModeIDTags(CYBRBIDTG_Depth,depth,
   28.85 -						CYBRBIDTG_NominalWidth,640,
   28.86 -						CYBRBIDTG_NominalHeight,480,
   28.87 -						TAG_DONE);
   28.88 -
   28.89 -	if(tID!=INVALID_ID)
   28.90 -	{
   28.91 -		int n = this->hidden->nvisuals;
   28.92 -
   28.93 -		this->hidden->visuals[n].depth = depth;
   28.94 -		this->hidden->visuals[n].visual = tID;
   28.95 -		this->hidden->visuals[n].bpp = GetCyberIDAttr(CYBRIDATTR_BPPIX,tID);
   28.96 -		this->hidden->nvisuals++;
   28.97 -	}
   28.98 -}
   28.99 -
  28.100 -#define TrueColor 1
  28.101 -#define PseudoColor 2
  28.102 -
  28.103 -int CGX_GetVideoModes(_THIS)
  28.104 -{
  28.105 -    int i;
  28.106 -	ULONG nextid;
  28.107 -	int nmodes=0;
  28.108 -
  28.109 -	SDL_modelist=NULL;
  28.110 -
  28.111 -	nextid=NextDisplayInfo(INVALID_ID);
  28.112 -
  28.113 -	while(nextid!=INVALID_ID)
  28.114 -	{
  28.115 -		if(IsCyberModeID(nextid))
  28.116 -		{
  28.117 -			DisplayInfoHandle h;
  28.118 -
  28.119 -			if(h=FindDisplayInfo(nextid))
  28.120 -			{
  28.121 -				struct DimensionInfo info;
  28.122 -
  28.123 -				if(GetDisplayInfoData(h,(char *)&info,sizeof(struct DimensionInfo),DTAG_DIMS,NULL))
  28.124 -				{
  28.125 -					int ok=0;
  28.126 -
  28.127 -					for(i=0;i<nmodes;i++)
  28.128 -					{
  28.129 -						if(	SDL_modelist[i]->w == (info.Nominal.MaxX+1) &&
  28.130 -							SDL_modelist[i]->h == (info.Nominal.MaxY+1) )
  28.131 -							ok=1;
  28.132 -					}
  28.133 -
  28.134 -					if(!ok)
  28.135 -					{
  28.136 -						nmodes++;
  28.137 -
  28.138 -						SDL_modelist = (SDL_Rect **)SDL_realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *));
  28.139 -						SDL_modelist[nmodes]=NULL;
  28.140 -
  28.141 -						if ( SDL_modelist )
  28.142 -						{
  28.143 -							SDL_modelist[nmodes-1] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
  28.144 -
  28.145 -							if ( SDL_modelist[nmodes-1] == NULL )
  28.146 -								break;
  28.147 -
  28.148 -							SDL_modelist[nmodes-1]->x = 0;
  28.149 -							SDL_modelist[nmodes-1]->y = 0;
  28.150 -							SDL_modelist[nmodes-1]->w = info.Nominal.MaxX+1;
  28.151 -							SDL_modelist[nmodes-1]->h = info.Nominal.MaxY+1;
  28.152 -						}
  28.153 -					}
  28.154 -				}
  28.155 -			}
  28.156 -		}
  28.157 -		nextid=NextDisplayInfo(nextid);
  28.158 -	}
  28.159 -
  28.160 -
  28.161 -	this->hidden->nvisuals = 0;
  28.162 -	/* Search for the visuals in deepest-first order, so that the first
  28.163 -	   will be the richest one */
  28.164 -	add_visual(this, 32, TrueColor);
  28.165 -	add_visual(this, 24, TrueColor);
  28.166 -	add_visual(this, 16, TrueColor);
  28.167 -	add_visual(this, 15, TrueColor);
  28.168 -	add_visual(this, 8, PseudoColor);
  28.169 -
  28.170 -	if(this->hidden->nvisuals == 0) {
  28.171 -	    SDL_SetError("Found no sufficiently capable CGX visuals");
  28.172 -		    return -1;
  28.173 -	}
  28.174 -
  28.175 -    if ( SDL_modelist == NULL ) {
  28.176 -        SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *));
  28.177 -        i = 0;
  28.178 -        if ( SDL_modelist ) {
  28.179 -            SDL_modelist[i] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
  28.180 -            if ( SDL_modelist[i] ) {
  28.181 -                SDL_modelist[i]->x = 0;
  28.182 -                SDL_modelist[i]->y = 0;
  28.183 -                SDL_modelist[i]->w = SDL_Display->Width;
  28.184 -                SDL_modelist[i]->h = SDL_Display->Height;
  28.185 -                ++i;
  28.186 -            }
  28.187 -            SDL_modelist[i] = NULL;
  28.188 -        }
  28.189 -    }
  28.190 -
  28.191 -    D( if ( SDL_modelist ) {
  28.192 -        bug("CGX video mode list: (%ld)\n",nmodes);
  28.193 -        for ( i=0; SDL_modelist[i]; ++i ) {
  28.194 -            bug( "\t%ld x %ld\n",
  28.195 -                SDL_modelist[i]->w, SDL_modelist[i]->h);
  28.196 -        }
  28.197 -    	}
  28.198 -    );
  28.199 -
  28.200 -    D(  { bug("CGX visuals list: (%ld)\n",this->hidden->nvisuals);
  28.201 -
  28.202 -	for(i=0;i<this->hidden->nvisuals;i++)
  28.203 -		bug("\t%lx - depth: %ld bpp: %ld\n",this->hidden->visuals[i].visual,this->hidden->visuals[i].depth,this->hidden->visuals[i].bpp);
  28.204 -	}
  28.205 -    );
  28.206 -    return 0;
  28.207 -}
  28.208 -
  28.209 -int CGX_SupportedVisual(_THIS, SDL_PixelFormat *format)
  28.210 -{
  28.211 -    int i;
  28.212 -    for(i = 0; i < this->hidden->nvisuals; i++)
  28.213 -	{
  28.214 -		if(this->hidden->visuals[i].depth == format->BitsPerPixel) // Era bpp
  28.215 -		    return 1;
  28.216 -	}
  28.217 -    return 0;
  28.218 -}
  28.219 -
  28.220 -SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
  28.221 -{
  28.222 -    if ( CGX_SupportedVisual(this, format) ) {
  28.223 -        if ( flags & SDL_FULLSCREEN ) {
  28.224 -            return(SDL_modelist);
  28.225 -        } else {
  28.226 -            return((SDL_Rect **)-1);
  28.227 -        }
  28.228 -    } else {
  28.229 -        return((SDL_Rect **)0);
  28.230 -    }
  28.231 -}
  28.232 -
  28.233 -void CGX_FreeVideoModes(_THIS)
  28.234 -{
  28.235 -    int i;
  28.236 -
  28.237 -    if ( SDL_modelist ) {
  28.238 -        for ( i=0; SDL_modelist[i]; ++i ) {
  28.239 -            SDL_free(SDL_modelist[i]);
  28.240 -        }
  28.241 -        SDL_free(SDL_modelist);
  28.242 -        SDL_modelist = NULL;
  28.243 -    }
  28.244 -}
  28.245 -
  28.246 -int CGX_ResizeFullScreen(_THIS)
  28.247 -{
  28.248 -    int x, y;
  28.249 -    int real_w, real_h;
  28.250 -
  28.251 -    if ( currently_fullscreen ) {
  28.252 -/* Per ora non faccio nulla qui */
  28.253 -    }
  28.254 -    return(1);
  28.255 -}
  28.256 -
  28.257 -void _QueueEnterFullScreen(_THIS)
  28.258 -{
  28.259 -}
  28.260 -
  28.261 -int CGX_EnterFullScreen(_THIS)
  28.262 -{
  28.263 -    int okay;
  28.264 -	 Uint32 saved_flags;
  28.265 -
  28.266 -    okay = 1;
  28.267 -    saved_flags = this->screen->flags;
  28.268 -
  28.269 -    if ( ! currently_fullscreen )
  28.270 -	{
  28.271 -        int real_w, real_h;
  28.272 -
  28.273 -        /* Map the fullscreen window to blank the screen */
  28.274 -        get_real_resolution(this, &real_w, &real_h);
  28.275 -
  28.276 -		CGX_DestroyWindow(this,this->screen);
  28.277 -		set_best_resolution(this, real_w,real_h);
  28.278 -
  28.279 -        currently_fullscreen = 1;
  28.280 -		  this->screen->flags = saved_flags;
  28.281 -
  28.282 -		  CGX_CreateWindow(this,this->screen,real_w,real_h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags);
  28.283 -
  28.284 -        /* Set the new resolution */
  28.285 -        okay = CGX_ResizeFullScreen(this);
  28.286 -        if ( ! okay ) {
  28.287 -            CGX_LeaveFullScreen(this);
  28.288 -        }
  28.289 -	/* Set the colormap */
  28.290 -/*
  28.291 -		if ( SDL_XColorMap ) {
  28.292 -			XInstallColormap(SDL_Display, SDL_XColorMap);
  28.293 -		}
  28.294 -*/
  28.295 -    }
  28.296 -//    CGX_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
  28.297 -    return(okay);
  28.298 -}
  28.299 -
  28.300 -int CGX_LeaveFullScreen(_THIS)
  28.301 -{
  28.302 -    if ( currently_fullscreen ) {
  28.303 -		int width,height;
  28.304 -		if ( SDL_Window ) {
  28.305 -			CloseWindow(SDL_Window);
  28.306 -			SDL_Window=NULL;
  28.307 -		}
  28.308 -		CloseScreen(SDL_Display);
  28.309 -
  28.310 -		GFX_Display=SDL_Display=LockPubScreen(NULL);
  28.311 -
  28.312 -	        currently_fullscreen = 0;
  28.313 -
  28.314 -		CGX_CreateWindow(this,this->screen,this->screen->w,this->screen->h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags);
  28.315 -		CGX_ResizeImage(this,this->screen,0L);
  28.316 -    }
  28.317 -
  28.318 -    return(0);
  28.319 -}
    29.1 --- a/src/video/cybergfx/SDL_cgxmodes_c.h	Sun Oct 29 03:44:25 2006 +0000
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,45 +0,0 @@
    29.4 -/*
    29.5 -    SDL - Simple DirectMedia Layer
    29.6 -    Copyright (C) 1997-2006 Sam Lantinga
    29.7 -
    29.8 -    This library is free software; you can redistribute it and/or
    29.9 -    modify it under the terms of the GNU Lesser General Public
   29.10 -    License as published by the Free Software Foundation; either
   29.11 -    version 2.1 of the License, or (at your option) any later version.
   29.12 -
   29.13 -    This library is distributed in the hope that it will be useful,
   29.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   29.16 -    Lesser General Public License for more details.
   29.17 -
   29.18 -    You should have received a copy of the GNU Lesser General Public
   29.19 -    License along with this library; if not, write to the Free Software
   29.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   29.21 -
   29.22 -    Sam Lantinga
   29.23 -    slouken@libsdl.org
   29.24 -*/
   29.25 -#include "SDL_config.h"
   29.26 -
   29.27 -/* Utilities for getting and setting the X display mode */
   29.28 -
   29.29 -#include "SDL_cgxvideo.h"
   29.30 -
   29.31 -/* Define this if you want to grab the keyboard in fullscreen mode.
   29.32 -   If you do not define this, SDL will return from SDL_SetVideoMode()
   29.33 -   immediately, but will not actually go fullscreen until the window
   29.34 -   manager is idle.
   29.35 -*/
   29.36 -#define GRAB_FULLSCREEN
   29.37 -
   29.38 -extern int CGX_GetVideoModes(_THIS);
   29.39 -extern SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
   29.40 -extern void CGX_FreeVideoModes(_THIS);
   29.41 -extern int CGX_ResizeFullScreen(_THIS);
   29.42 -/*
   29.43 -extern void CGX_WaitMapped(_THIS, Window win);
   29.44 -extern void CGX_WaitUnmapped(_THIS, Window win);
   29.45 -extern void CGX_QueueEnterFullScreen(_THIS);
   29.46 -*/
   29.47 -extern int CGX_EnterFullScreen(_THIS);
   29.48 -extern int CGX_LeaveFullScreen(_THIS);
    30.1 --- a/src/video/cybergfx/SDL_cgxvideo.c	Sun Oct 29 03:44:25 2006 +0000
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,1375 +0,0 @@
    30.4 -/*
    30.5 -    SDL - Simple DirectMedia Layer
    30.6 -    Copyright (C) 1997-2006 Sam Lantinga
    30.7 -
    30.8 -    This library is free software; you can redistribute it and/or
    30.9 -    modify it under the terms of the GNU Lesser General Public
   30.10 -    License as published by the Free Software Foundation; either
   30.11 -    version 2.1 of the License, or (at your option) any later version.
   30.12 -
   30.13 -    This library is distributed in the hope that it will be useful,
   30.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   30.16 -    Lesser General Public License for more details.
   30.17 -
   30.18 -    You should have received a copy of the GNU Lesser General Public
   30.19 -    License along with this library; if not, write to the Free Software
   30.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   30.21 -
   30.22 -    Sam Lantinga
   30.23 -    slouken@libsdl.org
   30.24 -*/
   30.25 -#include "SDL_config.h"
   30.26 -
   30.27 -/*
   30.28 - * CGX based SDL video driver implementation by Gabriele Greco
   30.29 - * gabriele.greco@aruba.it
   30.30 - */
   30.31 -
   30.32 -#include "SDL_endian.h"
   30.33 -#include "SDL_timer.h"
   30.34 -#include "SDL_thread.h"
   30.35 -#include "SDL_video.h"
   30.36 -#include "SDL_mouse.h"
   30.37 -#include "../SDL_sysvideo.h"
   30.38 -#include "../SDL_pixels_c.h"
   30.39 -#include "../../events/SDL_events_c.h"
   30.40 -#include "SDL_cgxgl_c.h"
   30.41 -#include "SDL_cgxvideo.h"
   30.42 -#include "SDL_cgxwm_c.h"
   30.43 -#include "SDL_amigamouse_c.h"
   30.44 -#include "SDL_amigaevents_c.h"
   30.45 -#include "SDL_cgxmodes_c.h"
   30.46 -#include "SDL_cgximage_c.h"
   30.47 -
   30.48 -/* Initialization/Query functions */
   30.49 -static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat);
   30.50 -static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
   30.51 -static int CGX_ToggleFullScreen(_THIS, int on);
   30.52 -static void CGX_UpdateMouse(_THIS);
   30.53 -static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
   30.54 -static void CGX_VideoQuit(_THIS);
   30.55 -
   30.56 -/* CGX driver bootstrap functions */
   30.57 -
   30.58 -struct Library *CyberGfxBase=NULL;
   30.59 -struct IntuitionBase *IntuitionBase=NULL;
   30.60 -struct GfxBase *GfxBase=NULL;
   30.61 -
   30.62 -int CGX_SetGamma(_THIS, float red, float green, float blue)
   30.63 -{
   30.64 -    SDL_SetError("Gamma correction not supported");
   30.65 -    return -1;
   30.66 -}
   30.67 -
   30.68 -int CGX_GetGamma(_THIS, float red, float green, float blue)
   30.69 -{
   30.70 -    SDL_SetError("Gamma correction not supported");
   30.71 -    return -1;
   30.72 -}
   30.73 -
   30.74 -int CGX_SetGammaRamp(_THIS, Uint16 *ramp)
   30.75 -{
   30.76 -#if 0
   30.77 -	Int i, ncolors;
   30.78 -	XColor xcmap[256];
   30.79 -
   30.80 -	/* See if actually setting the gamma is supported */
   30.81 -	if ( SDL_Visual->class != DirectColor ) {
   30.82 -	    SDL_SetError("Gamma correction not supported on this visual");
   30.83 -	    return(-1);
   30.84 -	}
   30.85 -
   30.86 -	/* Calculate the appropriate palette for the given gamma ramp */
   30.87 -	ncolors = SDL_Visual->map_entries;
   30.88 -	for ( i=0; i<ncolors; ++i ) {
   30.89 -		Uint8 c = (256 * i / ncolors);
   30.90 -		xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c);
   30.91 -		xcmap[i].red   = ramp[0*256+c];
   30.92 -		xcmap[i].green = ramp[1*256+c];
   30.93 -		xcmap[i].blue  = ramp[2*256+c];
   30.94 -		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
   30.95 -	}
   30.96 -	XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
   30.97 -	XSync(GFX_Display, False);
   30.98 -
   30.99 -	return(0);
  30.100 -
  30.101 -#else
  30.102 -    SDL_SetError("Gamma correction not supported on this visual");
  30.103 -    return(-1);
  30.104 -
  30.105 -#endif
  30.106 -}
  30.107 -
  30.108 -static void DestroyScreen(_THIS)
  30.109 -{
  30.110 -  	if(currently_fullscreen)
  30.111 -	{
  30.112 -		if(this->hidden->dbuffer)
  30.113 -		{
  30.114 -			extern struct MsgPort *safeport,*dispport;
  30.115 -
  30.116 -			this->hidden->dbuffer=0;
  30.117 -
  30.118 -			if(safeport)
  30.119 -			{
  30.120 -				while(GetMsg(safeport)!=NULL);
  30.121 -				DeleteMsgPort(safeport);
  30.122 -			}
  30.123 -			if(dispport)
  30.124 -			{
  30.125 -				while(GetMsg(dispport)!=NULL);
  30.126 -				DeleteMsgPort(dispport);
  30.127 -			}
  30.128 -
  30.129 -			this->hidden->SB[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[0]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL;
  30.130 -			this->hidden->SB[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL;
  30.131 -
  30.132 -			if(this->hidden->SB[1])
  30.133 -				FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
  30.134 -			if(this->hidden->SB[0])
  30.135 -				FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
  30.136 -
  30.137 -
  30.138 -			this->hidden->SB[0]=this->hidden->SB[1]=NULL;
  30.139 -
  30.140 -			if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort)
  30.141 -				SDL_free(SDL_RastPort);
  30.142 -
  30.143 -			SDL_RastPort=NULL;
  30.144 -		}
  30.145 -		CloseScreen(GFX_Display);
  30.146 -		currently_fullscreen=0;
  30.147 -	}
  30.148 -	else if(GFX_Display)
  30.149 -		UnlockPubScreen(NULL,GFX_Display);
  30.150 -
  30.151 -	GFX_Display = NULL;
  30.152 -}
  30.153 -
  30.154 -static int CGX_Available(void)
  30.155 -{
  30.156 -	struct Library *l;
  30.157 -
  30.158 -	l = OpenLibrary("cybergraphics.library",0L);
  30.159 -
  30.160 -	if ( l != NULL ) {
  30.161 -		D(bug("CGX video device AVAILABLE\n"));
  30.162 -		CloseLibrary(l);
  30.163 -	}
  30.164 -	D(else bug("**CGX video device UNAVAILABLE\n"));
  30.165 -
  30.166 -	return(l != NULL);
  30.167 -}
  30.168 -
  30.169 -static void CGX_DeleteDevice(SDL_VideoDevice *device)
  30.170 -{
  30.171 -	if ( device ) {
  30.172 -		if ( device->hidden ) {
  30.173 -			SDL_free(device->hidden);
  30.174 -		}
  30.175 -		if ( device->gl_data ) {
  30.176 -			SDL_free(device->gl_data);
  30.177 -		}
  30.178 -		SDL_free(device);
  30.179 -	}
  30.180 -}
  30.181 -
  30.182 -static SDL_VideoDevice *CGX_CreateDevice(int devindex)
  30.183 -{
  30.184 -	SDL_VideoDevice *device;
  30.185 -
  30.186 -	/* Initialize all variables that we clean on shutdown */
  30.187 -	device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
  30.188 -	if ( device ) {
  30.189 -		SDL_memset(device, 0, (sizeof *device));
  30.190 -		device->hidden = (struct SDL_PrivateVideoData *)
  30.191 -				SDL_malloc((sizeof *device->hidden));
  30.192 -		device->gl_data = (struct SDL_PrivateGLData *)
  30.193 -				SDL_malloc((sizeof *device->gl_data));
  30.194 -	}
  30.195 -	if ( (device == NULL) || (device->hidden == NULL) ||
  30.196 -	                         (device->gl_data == NULL) ) {
  30.197 -		D(bug("Unable to create video device!\n"));
  30.198 -		SDL_OutOfMemory();
  30.199 -		CGX_DeleteDevice(device);
  30.200 -		return(0);
  30.201 -	}
  30.202 -	SDL_memset(device->hidden, 0, sizeof(*device->hidden));
  30.203 -	SDL_memset(device->gl_data, 0, sizeof(*device->gl_data));
  30.204 -
  30.205 -	/* Set the driver flags */
  30.206 -	device->handles_any_size = 1;
  30.207 -
  30.208 -	/* Set the function pointers */
  30.209 -	device->VideoInit = CGX_VideoInit;
  30.210 -	device->ListModes = CGX_ListModes;
  30.211 -	device->SetVideoMode = CGX_SetVideoMode;
  30.212 -	device->ToggleFullScreen = CGX_ToggleFullScreen;
  30.213 -	device->UpdateMouse = CGX_UpdateMouse;
  30.214 -	device->SetColors = CGX_SetColors;
  30.215 -	device->UpdateRects = NULL;
  30.216 -	device->VideoQuit = CGX_VideoQuit;
  30.217 -	device->AllocHWSurface = CGX_AllocHWSurface;
  30.218 -	device->CheckHWBlit = CGX_CheckHWBlit;
  30.219 -	device->FillHWRect = CGX_FillHWRect;
  30.220 -	device->SetHWColorKey = CGX_SetHWColorKey;
  30.221 -	device->SetHWAlpha = NULL;
  30.222 -	device->LockHWSurface = CGX_LockHWSurface;
  30.223 -	device->UnlockHWSurface = CGX_UnlockHWSurface;
  30.224 -	device->FlipHWSurface = CGX_FlipHWSurface;
  30.225 -	device->FreeHWSurface = CGX_FreeHWSurface;
  30.226 -	device->SetGamma = CGX_SetGamma;
  30.227 -	device->GetGamma = CGX_GetGamma;
  30.228 -	device->SetGammaRamp = CGX_SetGammaRamp;
  30.229 -	device->GetGammaRamp = NULL;
  30.230 -#if SDL_VIDEO_OPENGL
  30.231 -	device->GL_LoadLibrary = CGX_GL_LoadLibrary;
  30.232 -	device->GL_GetProcAddress = CGX_GL_GetProcAddress;
  30.233 -	device->GL_GetAttribute = CGX_GL_GetAttribute;
  30.234 -	device->GL_MakeCurrent = CGX_GL_MakeCurrent;
  30.235 -	device->GL_SwapBuffers = CGX_GL_SwapBuffers;
  30.236 -#endif
  30.237 -	device->SetIcon = CGX_SetIcon;
  30.238 -	device->SetCaption = CGX_SetCaption;
  30.239 -	device->IconifyWindow = NULL; /* CGX_IconifyWindow; */
  30.240 -	device->GrabInput = NULL /* CGX_GrabInput*/;
  30.241 -	device->GetWMInfo = CGX_GetWMInfo;
  30.242 -	device->FreeWMCursor = amiga_FreeWMCursor;
  30.243 -	device->CreateWMCursor = amiga_CreateWMCursor;
  30.244 -	device->ShowWMCursor = amiga_ShowWMCursor;
  30.245 -	device->WarpWMCursor = amiga_WarpWMCursor;
  30.246 -	device->CheckMouseMode = amiga_CheckMouseMode;
  30.247 -	device->InitOSKeymap = amiga_InitOSKeymap;
  30.248 -	device->PumpEvents = amiga_PumpEvents;
  30.249 -
  30.250 -	device->free = CGX_DeleteDevice;
  30.251 -
  30.252 -	return device;
  30.253 -}
  30.254 -
  30.255 -VideoBootStrap CGX_bootstrap = {
  30.256 -	"CGX", "AmigaOS CyberGraphics", CGX_Available, CGX_CreateDevice
  30.257 -};
  30.258 -
  30.259 -Uint32 MakeBitMask(_THIS,int type,int format,int *bpp)
  30.260 -{
  30.261 -	D(if(type==0)bug("REAL pixel format: "));
  30.262 -
  30.263 -	if(this->hidden->depth==*bpp)
  30.264 -	{
  30.265 -
  30.266 -	switch(format)
  30.267 -    	{
  30.268 -		case PIXFMT_LUT8:
  30.269 -			D(if(type==0)bug("LUT8\n"));
  30.270 -			return 0;
  30.271 -		case PIXFMT_BGR15:
  30.272 -		case PIXFMT_RGB15PC:
  30.273 -			switch(type)
  30.274 -			{
  30.275 -				case 0:
  30.276 -					D(bug("RGB15PC/BGR15\n"));
  30.277 -					return 31;
  30.278 -				case 1:
  30.279 -					return 992;
  30.280 -				case 2:
  30.281 -					return 31744;
  30.282 -			}
  30.283 -		case PIXFMT_RGB15:
  30.284 -		case PIXFMT_BGR15PC:
  30.285 -			switch(type)
  30.286 -			{
  30.287 -				case 0:
  30.288 -					D(bug("RGB15/BGR15PC\n"));
  30.289 -					return 31744;
  30.290 -				case 1:
  30.291 -					return 992;
  30.292 -				case 2:
  30.293 -					return 31;
  30.294 -			}
  30.295 -		case PIXFMT_BGR16PC:
  30.296 -		case PIXFMT_RGB16:
  30.297 -			switch(type)
  30.298 -			{
  30.299 -				case 0:
  30.300 -					D(bug("RGB16PC\n"));
  30.301 -					return 63488;
  30.302 -				case 1:
  30.303 -					return 2016;
  30.304 -				case 2:
  30.305 -					return 31;
  30.306 -			}
  30.307 -		case PIXFMT_BGR16:
  30.308 -		case PIXFMT_RGB16PC:
  30.309 -			switch(type)
  30.310 -			{
  30.311 -				case 0:
  30.312 -					D(bug("RGB16PC/BGR16\n"));
  30.313 -					return 31;
  30.314 -				case 1:
  30.315 -					return 2016;
  30.316 -				case 2:
  30.317 -					return 63488;
  30.318 -			}
  30.319 -
  30.320 -		case PIXFMT_RGB24:
  30.321 -			switch(type)
  30.322 -			{
  30.323 -				case 0:
  30.324 -					D(bug("RGB24/BGR24\n"));
  30.325 -					return 0xff0000;
  30.326 -				case 1:
  30.327 -					return 0xff00;
  30.328 -				case 2:
  30.329 -					return 0xff;
  30.330 -			}
  30.331 -		case PIXFMT_BGR24:
  30.332 -			switch(type)
  30.333 -			{
  30.334 -				case 0:
  30.335 -					D(bug("BGR24\n"));
  30.336 -					return 0xff;
  30.337 -				case 1:
  30.338 -					return 0xff00;
  30.339 -				case 2:
  30.340 -					return 0xff0000;
  30.341 -			}
  30.342 -		case PIXFMT_ARGB32:
  30.343 -			switch(type)
  30.344 -			{
  30.345 -				case 0:
  30.346 -					D(bug("ARGB32\n"));
  30.347 -					return 0xff0000;
  30.348 -				case 1:
  30.349 -					return 0xff00;
  30.350 -				case 2:
  30.351 -					return 0xff;
  30.352 -			}
  30.353 -		case PIXFMT_BGRA32:
  30.354 -			switch(type)
  30.355 -			{
  30.356 -				case 0:
  30.357 -					D(bug("BGRA32\n"));
  30.358 -					return 0xff00;
  30.359 -				case 1:
  30.360 -					return 0xff0000;
  30.361 -				case 2:
  30.362 -					return 0xff000000;
  30.363 -			}
  30.364 -		case PIXFMT_RGBA32:
  30.365 -			switch(type)
  30.366 -			{
  30.367 -				case 0:
  30.368 -					D(bug("RGBA32\n"));
  30.369 -					return 0xff000000;
  30.370 -				case 1:
  30.371 -					return 0xff0000;
  30.372 -				case 2:
  30.373 -					return 0xff00;
  30.374 -			}
  30.375 -		default:
  30.376 -			D(bug("Unknown pixel format! Default to 24bit\n"));
  30.377 -			return (Uint32) (255<<(type*8));
  30.378 -	}
  30.379 -	}
  30.380 -	else
  30.381 -	{
  30.382 -		D(if(type==0)bug("DIFFERENT from screen.\nAllocated screen format: "));
  30.383 -
  30.384 -		switch(*bpp)
  30.385 -		{
  30.386 -			case 32:
  30.387 -				D(if(type==0) bug("RGBA32\n"));
  30.388 -				switch(type)
  30.389 -				{
  30.390 -					case 0:
  30.391 -						return 0xff000000;
  30.392 -					case 1:
  30.393 -						return 0xff0000;
  30.394 -					case 2:
  30.395 -						return 0xff00;
  30.396 -				}
  30.397 -				break;
  30.398 -			case 24:
  30.399 -use_truecolor:
  30.400 -				switch(type)
  30.401 -				{
  30.402 -					case 0:
  30.403 -						D(bug("RGB24\n"));
  30.404 -						return 0xff0000;
  30.405 -					case 1:
  30.406 -						return 0xff00;
  30.407 -					case 2:
  30.408 -						return 0xff;
  30.409 -				}
  30.410 -			case 16:
  30.411 -			case 15:
  30.412 -				D(if(type==0) bug("Not supported, switching to 24bit!\n"));
  30.413 -				*bpp=24;
  30.414 -				goto use_truecolor;
  30.415 -				break;
  30.416 -			default:
  30.417 -				D(if(type==0)bug("This is a chunky display\n"));
  30.418 -// For chunky display mask is always 0;
  30.419 -				return 0;
  30.420 -		}
  30.421 -	}
  30.422 -	return 0;
  30.423 -}
  30.424 -
  30.425 -static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat)
  30.426 -{
  30.427 -	int i;
  30.428 -	struct Library *RTGBase;
  30.429 -
  30.430 -	D(bug("VideoInit... Opening libraries\n"));
  30.431 -
  30.432 -	if(!IntuitionBase) {
  30.433 -		if( !(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39L))) {
  30.434 -			SDL_SetError("Couldn't open intuition V39+");
  30.435 -			return -1;
  30.436 -		}
  30.437 -	}
  30.438 -
  30.439 -	if(!GfxBase) {
  30.440 -		if( !(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39L))) {
  30.441 -			SDL_SetError("Couldn't open graphics V39+");
  30.442 -			return -1;
  30.443 -		}
  30.444 -	}
  30.445 -
  30.446 -	if(!CyberGfxBase) {
  30.447 -		if( !(CyberGfxBase=OpenLibrary("cybergraphics.library",40L))) {
  30.448 -			SDL_SetError("Couldn't open cybergraphics.");
  30.449 -			return(-1);
  30.450 -		}
  30.451 -	}
  30.452 -
  30.453 -	if(RTGBase=OpenLibrary("libs:picasso96/rtg.library",0L)) {
  30.454 -		extern int use_picasso96;
  30.455 -
  30.456 -		CloseLibrary(RTGBase);
  30.457 -		use_picasso96=1;
  30.458 -	}
  30.459 -
  30.460 -	D(bug("Library intialized, locking screen...\n"));
  30.461 -
  30.462 -	SDL_Display = LockPubScreen(NULL);
  30.463 -
  30.464 -	if ( SDL_Display == NULL ) {
  30.465 -		D(bug("Cannot lock display...\n"));
  30.466 -		SDL_SetError("Couldn't lock the display");
  30.467 -		return(-1);
  30.468 -	}
  30.469 -	this->info.current_w = SDL_Display->Width;
  30.470 -	this->info.current_h = SDL_Display->Height;
  30.471 -
  30.472 -	D(bug("Checking if we are using a CGX native display...\n"));
  30.473 -
  30.474 -	if(!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort)))
  30.475 -	{
  30.476 -		Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,SDL_Display->Width,
  30.477 -				CYBRBIDTG_NominalHeight,SDL_Display->Height,
  30.478 -				CYBRBIDTG_Depth,8,
  30.479 -				TAG_DONE);
  30.480 -
  30.481 -		D(bug("Default visual is not CGX native!\n"));
  30.482 -
  30.483 -		UnlockPubScreen(NULL,SDL_Display);
  30.484 -
  30.485 -		GFX_Display=NULL;
  30.486 -
  30.487 -		if(okid!=INVALID_ID)
  30.488 -		{
  30.489 -			GFX_Display=OpenScreenTags(NULL,
  30.490 -									SA_Width,SDL_Display->Width,
  30.491 -									SA_Height,SDL_Display->Height,
  30.492 -									SA_Depth,8,SA_Quiet,TRUE,
  30.493 -									SA_ShowTitle,FALSE,
  30.494 -									SA_DisplayID,okid,
  30.495 -									TAG_DONE);
  30.496 -		}
  30.497 -
  30.498 -		if(!GFX_Display)
  30.499 -		{
  30.500 -			SDL_SetError("Unable to open a suited CGX display");
  30.501 -			return -1;
  30.502 -		}
  30.503 -		else SDL_Display=GFX_Display;
  30.504 -
  30.505 -	}
  30.506 -	else GFX_Display = SDL_Display;
  30.507 -
  30.508 -
  30.509 -	/* See whether or not we need to swap pixels */
  30.510 -
  30.511 -	swap_pixels = 0;
  30.512 -
  30.513 -// Non e' detto che sia cosi' pero', alcune schede potrebbero gestire i modi in modo differente
  30.514 -
  30.515 -	if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) {
  30.516 -		swap_pixels = 1;
  30.517 -	}
  30.518 -
  30.519 -	D(bug("Before GetVideoModes....\n"));
  30.520 -
  30.521 -	/* Get the available video modes */
  30.522 -	if(CGX_GetVideoModes(this) < 0)
  30.523 -	    return -1;
  30.524 -
  30.525 -	/* Determine the default screen depth:
  30.526 -	   Use the default visual (or at least one with the same depth) */
  30.527 -
  30.528 -	for(i = 0; i < this->hidden->nvisuals; i++)
  30.529 -	    if(this->hidden->visuals[i].depth == GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH))
  30.530 -					break;
  30.531 -	if(i == this->hidden->nvisuals) {
  30.532 -	    /* default visual was useless, take the deepest one instead */
  30.533 -	    i = 0;
  30.534 -	}
  30.535 -	SDL_Visual = this->hidden->visuals[i].visual;
  30.536 -
  30.537 -//	SDL_XColorMap = SDL_DisplayColormap;
  30.538 -
  30.539 -	this->hidden->depth = this->hidden->visuals[i].depth;
  30.540 -	D(bug("Init: Setting screen depth to: %ld\n",this->hidden->depth));
  30.541 -	vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */
  30.542 -
  30.543 -	{
  30.544 -		int form;
  30.545 -		APTR handle;
  30.546 -		struct DisplayInfo info;
  30.547 -
  30.548 -		if(!(handle=FindDisplayInfo(this->hidden->visuals[i].visual)))
  30.549 -		{
  30.550 -			D(bug("Unable to get visual info...\n"));
  30.551 -			return -1;
  30.552 -		}
  30.553 -
  30.554 -		if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) {
  30.555 -			D(bug("Unable to get visual info data...\n"));
  30.556 -			return -1;
  30.557 -		}
  30.558 -
  30.559 -		form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
  30.560 -
  30.561 -// In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask
  30.562 -
  30.563 -		if ( vformat->BitsPerPixel > 8 )
  30.564 -		{
  30.565 -			vformat->Rmask = MakeBitMask(this,0,form,&this->hidden->depth);
  30.566 -	  		vformat->Gmask = MakeBitMask(this,1,form,&this->hidden->depth);
  30.567 -		  	vformat->Bmask = MakeBitMask(this,2,form,&this->hidden->depth);
  30.568 -		}
  30.569 -	}
  30.570 -
  30.571 -	/* See if we have been passed a window to use */
  30.572 -/*	SDL_windowid = SDL_getenv("SDL_WINDOWID"); */
  30.573 -	SDL_windowid=NULL;
  30.574 -
  30.575 -	/* Create the blank cursor */
  30.576 -	SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR);
  30.577 -
  30.578 -	/* Fill in some window manager capabilities */
  30.579 -	this->info.wm_available = 1;
  30.580 -	this->info.blit_hw = 1;
  30.581 -	this->info.blit_hw_CC = 1;
  30.582 -	this->info.blit_sw = 1;
  30.583 -	this->info.blit_fill = 1;
  30.584 -	this->info.video_mem=2000000; // Not always true but almost any Amiga card has this memory!
  30.585 -
  30.586 -	this->hidden->same_format=0;
  30.587 -	SDL_RastPort=&SDL_Display->RastPort;
  30.588 -	/* We're done! */
  30.589 -	D(bug("End of CGX_VideoInit\n"));
  30.590 -
  30.591 -	return(0);
  30.592 -}
  30.593 -
  30.594 -void CGX_DestroyWindow(_THIS, SDL_Surface *screen)
  30.595 -{
  30.596 -	D(bug("Destroy Window...\n"));
  30.597 -
  30.598 -	if ( ! SDL_windowid ) {
  30.599 -		/* Hide the managed window */
  30.600 -		int was_fullscreen=0;
  30.601 -
  30.602 -		/* Clean up OpenGL */
  30.603 -		if ( screen ) {
  30.604 -		screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT);
  30.605 -		}
  30.606 -
  30.607 -		if ( screen && (screen->flags & SDL_FULLSCREEN) ) {
  30.608 -			was_fullscreen=1;
  30.609 -			screen->flags &= ~SDL_FULLSCREEN;
  30.610 -//			CGX_LeaveFullScreen(this); tolto x crash
  30.611 -		}
  30.612 -
  30.613 -		/* Destroy the output window */
  30.614 -		if ( SDL_Window ) {
  30.615 -			CloseWindow(SDL_Window);
  30.616 -			SDL_Window=NULL;
  30.617 -		}
  30.618 -
  30.619 -		/* Free the colormap entries */
  30.620 -		if ( SDL_XPixels ) {
  30.621 -			int numcolors;
  30.622 -			unsigned long pixel;
  30.623 -
  30.624 -			if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen)
  30.625 -			{
  30.626 -				numcolors = 1<<this->screen->format->BitsPerPixel;
  30.627 -
  30.628 -				if(numcolors>256)
  30.629 -					numcolors=256;
  30.630 -
  30.631 -				if(!was_fullscreen&&this->hidden->depth==8)
  30.632 -				{
  30.633 -					for ( pixel=0; pixel<numcolors; pixel++ )
  30.634 -					{
  30.635 -						if(SDL_XPixels[pixel]>=0)
  30.636 -							ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]);
  30.637 -					}
  30.638 -				}
  30.639 -			}
  30.640 -			SDL_free(SDL_XPixels);
  30.641 -			SDL_XPixels = NULL;
  30.642 -		}
  30.643 -	}
  30.644 -}
  30.645 -
  30.646 -static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags)
  30.647 -{
  30.648 -	if ( flags & SDL_RESIZABLE ) {
  30.649 -		WindowLimits(SDL_Window, 32, 32,4096,4096);
  30.650 -	} else {
  30.651 -		WindowLimits(SDL_Window, w,h,w,h);
  30.652 -	}
  30.653 -	if ( flags & SDL_FULLSCREEN ) {
  30.654 -		flags&=~SDL_RESIZABLE;
  30.655 -	} else if ( SDL_getenv("SDL_VIDEO_CENTERED") ) {
  30.656 -		int display_w, display_h;
  30.657 -
  30.658 -		display_w = SDL_Display->Width;
  30.659 -		display_h = SDL_Display->Height;
  30.660 -		ChangeWindowBox(SDL_Window,(display_w - w - SDL_Window->BorderLeft-SDL_Window->BorderRight)/2,
  30.661 -					(display_h - h - SDL_Window->BorderTop-SDL_Window->BorderBottom)/2,
  30.662 -					w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
  30.663 -					h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
  30.664 -	}
  30.665 -}
  30.666 -
  30.667 -int CGX_CreateWindow(_THIS, SDL_Surface *screen,
  30.668 -			    int w, int h, int bpp, Uint32 flags)
  30.669 -{
  30.670 -#if 0
  30.671 -	int i, depth;
  30.672 -	Uint32 vis;
  30.673 -#endif
  30.674 -	D(bug("CGX_CreateWindow\n"));
  30.675 -
  30.676 -	/* If a window is already present, destroy it and start fresh */
  30.677 -	if ( SDL_Window ) {
  30.678 -		CGX_DestroyWindow(this, screen);
  30.679 -	}
  30.680 -
  30.681 -	/* See if we have been given a window id */
  30.682 -	if ( SDL_windowid ) {
  30.683 -		SDL_Window = (struct Window *)atol(SDL_windowid);
  30.684 -	} else {
  30.685 -		SDL_Window = 0;
  30.686 -	}
  30.687 -
  30.688 -	/* find out which visual we are going to use */
  30.689 -#if 0
  30.690 -/* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre
  30.691 -   hanno il pixel mode degli schermi.
  30.692 - */
  30.693 -	/*if ( flags & SDL_OPENGL ) {
  30.694 -		SDL_SetError("OpenGL not supported by the Amiga SDL!");
  30.695 -		return -1;
  30.696 -	}
  30.697 -	else {*/
  30.698 -		for ( i = 0; i < this->hidden->nvisuals; i++ ) {
  30.699 -			if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */
  30.700 -				break;
  30.701 -		}
  30.702 -		if ( i == this->hidden->nvisuals ) {
  30.703 -			SDL_SetError("No matching visual for requested depth");
  30.704 -			return -1;	/* should never happen */
  30.705 -		}
  30.706 -		vis = this->hidden->visuals[i].visual;
  30.707 -		depth = this->hidden->visuals[i].depth;
  30.708 -//	}
  30.709 -	SDL_Visual = vis;
  30.710 -	this->hidden->depth = depth;
  30.711 -	D(bug("Setting screen depth to: %ld\n",this->hidden->depth));
  30.712 -#endif
  30.713 -
  30.714 -	/* Allocate the new pixel format for this video mode */
  30.715 -	{
  30.716 -		Uint32 form;
  30.717 -		APTR handle;
  30.718 -		struct DisplayInfo info;
  30.719 -
  30.720 -		if(!(handle=FindDisplayInfo(SDL_Visual)))
  30.721 -			return -1;
  30.722 -
  30.723 -		if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL))
  30.724 -			return -1;
  30.725 -
  30.726 -		form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
  30.727 -
  30.728 -		if(flags&SDL_HWSURFACE)
  30.729 -		{
  30.730 -			if(bpp!=this->hidden->depth)
  30.731 -			{
  30.732 -				bpp=this->hidden->depth;
  30.733 -				D(bug("Accel forces bpp to be equal (%ld)\n",bpp));
  30.734 -			}
  30.735 -		}
  30.736 -
  30.737 -		D(bug("BEFORE screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth));
  30.738 -
  30.739 -/* With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs
  30.740 -   only with requested format 15/16bit and display format != 15/16bit
  30.741 - */
  30.742 -
  30.743 -		if ( ! SDL_ReallocFormat(screen, bpp,
  30.744 -				MakeBitMask(this,0,form,&bpp), MakeBitMask(this,1,form,&bpp), MakeBitMask(this,2,form,&bpp), 0) )
  30.745 -			return -1;
  30.746 -
  30.747 -		D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth));
  30.748 -
  30.749 -	}
  30.750 -
  30.751 -	/* Create the appropriate colormap */
  30.752 -/*
  30.753 -	if ( SDL_XColorMap != SDL_DisplayColormap ) {
  30.754 -		XFreeColormap(SDL_Display, SDL_XColorMap);
  30.755 -	}
  30.756 -*/
  30.757 -	if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) {
  30.758 -	    int ncolors,i;
  30.759 -	    D(bug("XPixels palette allocation...\n"));
  30.760 -
  30.761 -	    /* Allocate the pixel flags */
  30.762 -
  30.763 -	    if(bpp==8)
  30.764 -		ncolors=256;
  30.765 -	    else
  30.766 -		ncolors = 1 << screen->format->BitsPerPixel;
  30.767 -
  30.768 -	    SDL_XPixels = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32));
  30.769 -
  30.770 -	    if(SDL_XPixels == NULL) {
  30.771 -		SDL_OutOfMemory();
  30.772 -		return -1;
  30.773 -	    }
  30.774 -
  30.775 -
  30.776 -	    for(i=0;i<ncolors;i++)
  30.777 -		    SDL_XPixels[i]=-1;
  30.778 -
  30.779 -	    /* always allocate a private colormap on non-default visuals */
  30.780 -	    if(bpp==8)
  30.781 -		flags |= SDL_HWPALETTE;
  30.782 -
  30.783 -	    if ( flags & SDL_HWPALETTE )
  30.784 -			screen->flags |= SDL_HWPALETTE;
  30.785 -	} 
  30.786 -
  30.787 -	/* resize the (possibly new) window manager window */
  30.788 -
  30.789 -	/* Create (or use) the X11 display window */
  30.790 -
  30.791 -	if ( !SDL_windowid ) {
  30.792 -			if( flags & SDL_FULLSCREEN )
  30.793 -			{
  30.794 -				SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h,
  30.795 -											WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE,
  30.796 -											WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE,
  30.797 -											WA_CustomScreen,(ULONG)SDL_Display,
  30.798 -											TAG_DONE);
  30.799 -
  30.800 -				D(bug("Opening backdrop window %ldx%ld on display %lx!\n",w,h,SDL_Display));
  30.801 -			}
  30.802 -			else
  30.803 -			{
  30.804 -				/* Create GimmeZeroZero window when OpenGL is used */
  30.805 -				unsigned long gzz = FALSE;
  30.806 -				if( flags & SDL_OPENGL ) {
  30.807 -					gzz = TRUE;
  30.808 -				}
  30.809 -
  30.810 -				SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h,
  30.811 -											WA_Flags,WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP | ((flags&SDL_NOFRAME) ? 0 : (WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR | ((flags&SDL_RESIZABLE) ? WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM : 0))),
  30.812 -											WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE,
  30.813 -											WA_PubScreen,(ULONG)SDL_Display,
  30.814 -											WA_GimmeZeroZero, gzz,
  30.815 -														TAG_DONE);
  30.816 -				D(bug("Opening WB window of size: %ldx%ld!\n",w,h));
  30.817 -			}
  30.818 -
  30.819 -		if(!SDL_Window)
  30.820 -			return -1;
  30.821 -	}
  30.822 -
  30.823 -	this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX);
  30.824 -
  30.825 -	if(screen->flags & SDL_DOUBLEBUF)
  30.826 -	{
  30.827 -		if(SDL_RastPort=SDL_malloc(sizeof(struct RastPort)))
  30.828 -		{
  30.829 -			InitRastPort(SDL_RastPort);
  30.830 -			SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap;
  30.831 -		}
  30.832 -		else
  30.833 -			return -1;
  30.834 -	}
  30.835 -	else SDL_RastPort=SDL_Window->RPort;
  30.836 -
  30.837 -	if(flags&SDL_HWSURFACE)
  30.838 -		screen->flags|=SDL_HWSURFACE;
  30.839 -
  30.840 -	if( !SDL_windowid ) {
  30.841 -	    CGX_SetSizeHints(this, w, h, flags);
  30.842 -	}
  30.843 -
  30.844 -	/* Set our colormaps when not setting a GL mode */
  30.845 -/*
  30.846 -	if ( ! (flags & SDL_OPENGL) ) {
  30.847 -		XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap);
  30.848 -	}
  30.849 -*/
  30.850 -
  30.851 -	/* Map them both and go fullscreen, if requested */
  30.852 -	if ( ! SDL_windowid ) {
  30.853 -		if ( flags & SDL_FULLSCREEN ) {
  30.854 -			screen->flags |= SDL_FULLSCREEN;
  30.855 -			currently_fullscreen=1;
  30.856 -//			CGX_EnterFullScreen(this); Ci siamo gia'!
  30.857 -		} else {
  30.858 -			screen->flags &= ~SDL_FULLSCREEN;
  30.859 -		}
  30.860 -	}
  30.861 -	screen->w = w;
  30.862 -	screen->h = h;
  30.863 -	screen->pitch = SDL_CalculatePitch(screen);
  30.864 -	CGX_ResizeImage(this, screen, flags);
  30.865 -
  30.866 -	/* Make OpenGL Context if needed*/
  30.867 -	if(flags & SDL_OPENGL) {
  30.868 -		if(this->gl_data->gl_active == 0) {
  30.869 -			if(CGX_GL_Init(this) < 0)
  30.870 -				return -1;
  30.871 -			else
  30.872 -				screen->flags |= SDL_OPENGL;
  30.873 -		}
  30.874 -		else {
  30.875 -			if(CGX_GL_Update(this) < 0)
  30.876 -				return -1;
  30.877 -			else
  30.878 -				screen->flags |= SDL_OPENGL;
  30.879 -		}
  30.880 -	}
  30.881 -}
  30.882 -
  30.883 -int CGX_ResizeWindow(_THIS,
  30.884 -			SDL_Surface *screen, int w, int h, Uint32 flags)
  30.885 -{
  30.886 -	D(bug("CGX_ResizeWindow\n"));
  30.887 -
  30.888 -	if ( ! SDL_windowid ) {
  30.889 -		/* Resize the window manager window */
  30.890 -		CGX_SetSizeHints(this, w, h, flags);
  30.891 -
  30.892 -		ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
  30.893 -					h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
  30.894 -
  30.895 -		screen->w = w;
  30.896 -		screen->h = h;
  30.897 -		screen->pitch = SDL_CalculatePitch(screen);
  30.898 -		CGX_ResizeImage(this, screen, flags);
  30.899 -	}
  30.900 -	return(0);
  30.901 -}
  30.902 -
  30.903 -static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current,
  30.904 -				int width, int height, int bpp, Uint32 flags)
  30.905 -{
  30.906 -	Uint32 saved_flags;
  30.907 -	int needcreate=0;
  30.908 -
  30.909 -	D(bug("CGX_SetVideoMode current:%lx\n",current));
  30.910 -
  30.911 -	/* Lock the event thread, in multi-threading environments */
  30.912 -	SDL_Lock_EventThread();
  30.913 -
  30.914 -// Check if the window needs to be closed or can be resized
  30.915 -
  30.916 -	if( (flags&SDL_FULLSCREEN) || (current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)))
  30.917 -		needcreate=1;
  30.918 -
  30.919 -// Check if we need to close an already existing videomode...
  30.920 -
  30.921 -	if(current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)) {
  30.922 -		unsigned long i;
  30.923 -		D(bug("Destroying image, window & screen!\n"));
  30.924 -
  30.925 -		CGX_DestroyImage(this,current);
  30.926 -		CGX_DestroyWindow(this,current);
  30.927 -		DestroyScreen(this);
  30.928 -		GFX_Display=SDL_Display=LockPubScreen(NULL);
  30.929 -
  30.930 -		bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
  30.931 -
  30.932 -		for ( i = 0; i < this->hidden->nvisuals; i++ ) {
  30.933 -			if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */
  30.934 -				break;
  30.935 -		}
  30.936 -		if ( i == this->hidden->nvisuals ) {
  30.937 -			SDL_SetError("No matching visual for requested depth");
  30.938 -			return NULL;	/* should never happen */
  30.939 -		}
  30.940 -		SDL_Visual = this->hidden->visuals[i].visual;
  30.941 -
  30.942 -		D(bug("Setting screen depth to: %ld\n",this->hidden->depth));
  30.943 -
  30.944 -	}
  30.945 -	/* Check the combination of flags we were passed */
  30.946 -	if ( flags & SDL_FULLSCREEN ) {
  30.947 -		int i;
  30.948 -
  30.949 -		/* Clear fullscreen flag if not supported */
  30.950 -		if ( SDL_windowid ) {
  30.951 -			flags &= ~SDL_FULLSCREEN;
  30.952 -		}
  30.953 -		else if(current && current->flags&SDL_FULLSCREEN ) {
  30.954 -			if(current->w!=width ||
  30.955 -				current->h!=height ||
  30.956 -				(this->hidden && this->hidden->depth!=bpp))
  30.957 -			{
  30.958 -				D(bug("Deleting previous window...\n"));
  30.959 -				CGX_DestroyImage(this,current);
  30.960 -				CGX_DestroyWindow(this,current);
  30.961 -				DestroyScreen(this);
  30.962 -				goto buildnewscreen;
  30.963 -			}
  30.964 -		}
  30.965 -		else
  30.966 -buildnewscreen:
  30.967 -		{
  30.968 -			Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,width,
  30.969 -				CYBRBIDTG_NominalHeight,height,
  30.970 -				CYBRBIDTG_Depth,bpp,
  30.971 -				TAG_DONE);
  30.972 -
  30.973 -			GFX_Display=NULL;
  30.974 -
  30.975 -			D(bug("Opening screen...\n"));
  30.976 -
  30.977 -			if(okid!=INVALID_ID)
  30.978 -				GFX_Display=OpenScreenTags(NULL,
  30.979 -								SA_Width,width,
  30.980 -								SA_Height,height,
  30.981 -								SA_Quiet,TRUE,SA_ShowTitle,FALSE,
  30.982 -								SA_Depth,bpp,
  30.983 -								SA_DisplayID,okid,
  30.984 -								TAG_DONE);
  30.985 -
  30.986 -			if(!GFX_Display) {
  30.987 -				GFX_Display=SDL_Display;
  30.988 -				flags &= ~SDL_FULLSCREEN;
  30.989 -				flags &= ~SDL_DOUBLEBUF;
  30.990 -			}
  30.991 -			else {
  30.992 -				UnlockPubScreen(NULL,SDL_Display);
  30.993 -				SDL_Display=GFX_Display;
  30.994 -	
  30.995 -				D(bug("Screen opened.\n"));
  30.996 -
  30.997 -				if(flags&SDL_DOUBLEBUF) {
  30.998 -					int ok=0;
  30.999 -					D(bug("Start of DBuffering allocations...\n"));
 30.1000 -
 30.1001 -					if(this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP)) {
 30.1002 -
 30.1003 -						if(this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,0L)) {
 30.1004 -							extern struct MsgPort *safeport,*dispport;
 30.1005 -
 30.1006 -							safeport=CreateMsgPort();
 30.1007 -							dispport=CreateMsgPort();
 30.1008 -
 30.1009 -							if(!safeport || !dispport) {
 30.1010 -								if(safeport) {
 30.1011 -									DeleteMsgPort(safeport);
 30.1012 -									safeport=NULL;
 30.1013 -								}
 30.1014 -								if(dispport) {
 30.1015 -									DeleteMsgPort(dispport);
 30.1016 -									dispport=NULL;
 30.1017 -								}
 30.1018 -								FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
 30.1019 -								FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
 30.1020 -							}
 30.1021 -							else {
 30.1022 -								extern ULONG safe_sigbit,disp_sigbit;
 30.1023 -								int i;
 30.1024 -
 30.1025 -								safe_sigbit=1L<< safeport->mp_SigBit;
 30.1026 -								disp_sigbit=1L<< dispport->mp_SigBit;
 30.1027 -
 30.1028 -								for(i=0;i<2;i++) {
 30.1029 -									this->hidden->SB[i]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=safeport;
 30.1030 -									this->hidden->SB[i]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=dispport;
 30.1031 -								}
 30.1032 -
 30.1033 -								ok=1;
 30.1034 -								D(bug("Dbuffering enabled!\n"));
 30.1035 -								this->hidden->dbuffer=1;
 30.1036 -								current->flags|=SDL_DOUBLEBUF;
 30.1037 -							}
 30.1038 -						}
 30.1039 -						else {
 30.1040 -							FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
 30.1041 -							this->hidden->SB[0]=NULL;
 30.1042 -						}
 30.1043 -					}
 30.1044 -
 30.1045 -					if(!ok)
 30.1046 -						flags&=~SDL_DOUBLEBUF;
 30.1047 -				}
 30.1048 -			}
 30.1049 -
 30.1050 -			if(GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)==bpp)
 30.1051 -				this->hidden->same_format=1;
 30.1052 -		}
 30.1053 -
 30.1054 -		bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
 30.1055 -		D(bug("Setting screen depth to: %ld\n",this->hidden->depth));
 30.1056 -
 30.1057 -		for ( i = 0; i < this->hidden->nvisuals; i++ )
 30.1058 -			if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */
 30.1059 -				break;
 30.1060 -
 30.1061 -		if ( i == this->hidden->nvisuals ) {
 30.1062 -			SDL_SetError("No matching visual for requested depth");
 30.1063 -			return NULL;	/* should never happen */
 30.1064 -		}
 30.1065 -		SDL_Visual = this->hidden->visuals[i].visual;
 30.1066 -
 30.1067 -	}
 30.1068 -
 30.1069 -	/* Set up the X11 window */
 30.1070 -	saved_flags = current->flags;
 30.1071 -
 30.1072 -	if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL)
 30.1073 -	    && bpp == current->format->BitsPerPixel && !needcreate) {
 30.1074 -		if (CGX_ResizeWindow(this, current, width, height, flags) < 0) {
 30.1075 -			current = NULL;
 30.1076 -			goto done;
 30.1077 -		}
 30.1078 -	} else {
 30.1079 -		if (CGX_CreateWindow(this,current,width,height,bpp,flags) < 0) {
 30.1080 -			current = NULL;
 30.1081 -			goto done;
 30.1082 -		}
 30.1083 -	}
 30.1084 -
 30.1085 -#if 0
 30.1086 -	/* Set up the new mode framebuffer */
 30.1087 -	if ( ((current->w != width) || (current->h != height)) ||
 30.1088 -             ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) {
 30.1089 -		current->w = width;
 30.1090 -		current->h = height;
 30.1091 -		current->pitch = SDL_CalculatePitch(current);
 30.1092 -		CGX_ResizeImage(this, current, flags);
 30.1093 -	}
 30.1094 -#endif
 30.1095 -
 30.1096 -	current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it
 30.1097 -
 30.1098 -  done:
 30.1099 -	/* Release the event thread */
 30.1100 -	SDL_Unlock_EventThread();
 30.1101 -
 30.1102 -	/* We're done! */
 30.1103 -	return(current);
 30.1104 -}
 30.1105 -
 30.1106 -static int CGX_ToggleFullScreen(_THIS, int on)
 30.1107 -{
 30.1108 -	Uint32 event_thread;
 30.1109 -
 30.1110 -	/* Don't switch if we don't own the window */
 30.1111 -	if ( SDL_windowid ) {
 30.1112 -		return(0);
 30.1113 -	}
 30.1114 -
 30.1115 -	/* Don't lock if we are the event thread */
 30.1116 -	event_thread = SDL_EventThreadID();
 30.1117 -	if ( event_thread && (SDL_ThreadID() == event_thread) ) {
 30.1118 -		event_thread = 0;
 30.1119 -	}
 30.1120 -	if ( event_thread ) {
 30.1121 -		SDL_Lock_EventThread();
 30.1122 -	}
 30.1123 -	if ( on ) {
 30.1124 -		this->screen->flags |= SDL_FULLSCREEN;
 30.1125 -		CGX_EnterFullScreen(this);
 30.1126 -	} else {
 30.1127 -		this->screen->flags &= ~SDL_FULLSCREEN;
 30.1128 -		CGX_LeaveFullScreen(this);
 30.1129 -	}
 30.1130 -
 30.1131 -	CGX_RefreshDisplay(this);
 30.1132 -	if ( event_thread ) {
 30.1133 -		SDL_Unlock_EventThread();
 30.1134 -	}
 30.1135 -
 30.1136 -	SDL_ResetKeyboard();
 30.1137 -
 30.1138 -	return(1);
 30.1139 -}
 30.1140 -
 30.1141 -static void SetSingleColor(Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, unsigned char *c)
 30.1142 -{
 30.1143 -	switch(fmt)
 30.1144 -	{
 30.1145 -		case PIXFMT_BGR15:
 30.1146 -		case PIXFMT_RGB15PC:
 30.1147 -			{
 30.1148 -				Uint16 *t=(Uint16 *)c;
 30.1149 -				*t=(r>>3) | ((g>>3)<<5) | ((b>>3)<<10) ;
 30.1150 -			}
 30.1151 -			break;
 30.1152 -		case PIXFMT_RGB15:
 30.1153 -		case PIXFMT_BGR15PC:
 30.1154 -			{
 30.1155 -				Uint16 *t=(Uint16 *)c;
 30.1156 -				*t=(b>>3) | ((g>>3)<<5) | ((r>>3)<<10) ;
 30.1157 -			}
 30.1158 -			break;
 30.1159 -		case PIXFMT_BGR16PC:
 30.1160 -		case PIXFMT_RGB16:
 30.1161 -			{
 30.1162 -				Uint16 *t=(Uint16 *)c;
 30.1163 -				*t=(b>>3) | ((g>>2)<<5) | ((r>>3)<<11) ;
 30.1164 -			}
 30.1165 -			break;
 30.1166 -		case PIXFMT_BGR16:
 30.1167 -		case PIXFMT_RGB16PC:
 30.1168 -			{
 30.1169 -				Uint16 *t=(Uint16 *)c;
 30.1170 -				*t=(r>>3) | ((g>>2)<<5) | ((b>>3)<<11) ;
 30.1171 -			}
 30.1172 -			break;
 30.1173 -		case PIXFMT_RGB24:
 30.1174 -			c[0]=r;
 30.1175 -			c[1]=g;
 30.1176 -			c[2]=b;
 30.1177 -			c[3]=0;
 30.1178 -			break;
 30.1179 -		case PIXFMT_BGR24:
 30.1180 -			c[0]=b;
 30.1181 -			c[1]=g;
 30.1182 -			c[2]=r;
 30.1183 -			c[3]=0;
 30.1184 -			break;
 30.1185 -		case PIXFMT_ARGB32:
 30.1186 -			c[0]=0;
 30.1187 -			c[1]=r;
 30.1188 -			c[2]=g;
 30.1189 -			c[3]=b;
 30.1190 -			break;
 30.1191 -		case PIXFMT_BGRA32:
 30.1192 -			c[0]=b;
 30.1193 -			c[1]=g;
 30.1194 -			c[2]=r;
 30.1195 -			c[3]=0;
 30.1196 -			break;
 30.1197 -		case PIXFMT_RGBA32:
 30.1198 -			c[0]=r;
 30.1199 -			c[1]=g;
 30.1200 -			c[2]=b;
 30.1201 -			c[3]=0;
 30.1202 -			break;
 30.1203 -
 30.1204 -		default:
 30.1205 -			D(bug("Error, SetSingleColor with PIXFMT %ld!\n",fmt));
 30.1206 -	}
 30.1207 -}
 30.1208 -
 30.1209 -/* Update the current mouse state and position */
 30.1210 -static void CGX_UpdateMouse(_THIS)
 30.1211 -{
 30.1212 -	/* Lock the event thread, in multi-threading environments */
 30.1213 -	SDL_Lock_EventThread();
 30.1214 -
 30.1215 -	if(currently_fullscreen)
 30.1216 -	{
 30.1217 -			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
 30.1218 -			SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, SDL_Display->MouseY);
 30.1219 -	}
 30.1220 -	else
 30.1221 -	{
 30.1222 -		if(	SDL_Display->MouseX>=(SDL_Window->LeftEdge+SDL_Window->BorderLeft) && SDL_Display->MouseX<(SDL_Window->LeftEdge+SDL_Window->Width-SDL_Window->BorderRight) &&
 30.1223 -			SDL_Display->MouseY>=(SDL_Window->TopEdge+SDL_Window->BorderLeft) && SDL_Display->MouseY<(SDL_Window->TopEdge+SDL_Window->Height-SDL_Window->BorderBottom)
 30.1224 -			)
 30.1225 -		{
 30.1226 -			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
 30.1227 -			SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft,
 30.1228 -										SDL_Display->MouseY-SDL_Window->TopEdge-SDL_Window->BorderTop);
 30.1229 -		}
 30.1230 -		else
 30.1231 -		{
 30.1232 -			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
 30.1233 -		}
 30.1234 -	}
 30.1235 -	SDL_Unlock_EventThread();
 30.1236 -}
 30.1237 -
 30.1238 -static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
 30.1239 -{
 30.1240 -	int      i;
 30.1241 -
 30.1242 -	/* Check to make sure we have a colormap allocated */
 30.1243 -
 30.1244 -	/* It's easy if we have a hidden colormap */
 30.1245 -	if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen )
 30.1246 -	{
 30.1247 -		ULONG  xcmap[256*3+2];
 30.1248 -
 30.1249 -		xcmap[0]=(ncolors<<16);
 30.1250 -		xcmap[0]+=firstcolor;
 30.1251 -
 30.1252 -//		D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors));
 30.1253 -
 30.1254 -		for ( i=0; i<ncolors; i++ ) {
 30.1255 -			xcmap[i*3+1] = colors[i+firstcolor].r<<24;
 30.1256 -			xcmap[i*3+2] = colors[i+firstcolor].g<<24;
 30.1257 -			xcmap[i*3+3] = colors[i+firstcolor].b<<24;
 30.1258 -		}
 30.1259 -		xcmap[ncolors*3+1]=0;
 30.1260 -		LoadRGB32(&GFX_Display->ViewPort,xcmap);
 30.1261 -	} else {
 30.1262 -// XPixels are not needed on 8bit screen with hwpalette
 30.1263 -		unsigned long pixel;
 30.1264 -
 30.1265 -		if ( SDL_XPixels == NULL ) {
 30.1266 -			D(bug("SetColors without colormap!"));
 30.1267 -			return(0);
 30.1268 -		}
 30.1269 -
 30.1270 -		if(this->hidden->depth==8)
 30.1271 -		{
 30.1272 -// In this case I have to unalloc and realloc the full palette
 30.1273 -			D(bug("Obtaining %ld colors on the screen\n",ncolors));
 30.1274 -
 30.1275 -		/* Free existing allocated colors */
 30.1276 -			for ( pixel=0; pixel<this->screen->format->palette->ncolors; ++pixel ) {
 30.1277 -				if(SDL_XPixels[pixel]>=0)
 30.1278 -					ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]);
 30.1279 -			}
 30.1280 -
 30.1281 -		/* Try to allocate all the colors */
 30.1282 -			for ( i=0; i<this->screen->format->palette->ncolors; ++i ) {
 30.1283 -				SDL_XPixels[i]=ObtainBestPenA(GFX_Display->ViewPort.ColorMap,colors[i].r<<24,colors[i].g<<24,colors[i].b<<24,NULL);
 30.1284 -			}
 30.1285 -		}
 30.1286 -		else
 30.1287 -		{
 30.1288 -#ifndef USE_CGX_WRITELUTPIXEL
 30.1289 -			Uint32 fmt;
 30.1290 -			D(bug("Preparing a conversion pixel table...\n"));
 30.1291 -
 30.1292 -			fmt=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT);
 30.1293 -
 30.1294 -			for(i=0;i<ncolors;i++)
 30.1295 -			{
 30.1296 -				SetSingleColor(fmt,colors[firstcolor+i].r,colors[firstcolor+i].g,colors[firstcolor+i].b,(unsigned char *)&SDL_XPixels[firstcolor+i]);
 30.1297 -			}
 30.1298 -#else
 30.1299 -//			D(bug("Executing XPixel(%lx) remapping: (from %ld, %ld colors) first: r%ld g%ld b%ld\n",SDL_XPixels,firstcolor,ncolors,colors[firstcolor].r,colors[firstcolor].g,colors[firstcolor].b));
 30.1300 -			for(i=0;i<ncolors;i++)
 30.1301 -				SDL_XPixels[i+firstcolor]=(colors[firstcolor+i].r<<16)+(colors[firstcolor+i].g<<8)+colors[firstcolor+i].b;
 30.1302 -#endif
 30.1303 -		}
 30.1304 -	}
 30.1305 -
 30.1306 -// Actually it cannot fail!
 30.1307 -
 30.1308 -	return 1;
 30.1309 -}
 30.1310 -
 30.1311 -/* Note:  If we are terminated, this could be called in the middle of
 30.1312 -   another SDL video routine -- notably UpdateRects.
 30.1313 -*/
 30.1314 -static void CGX_VideoQuit(_THIS)
 30.1315 -{
 30.1316 -	/* Shutdown everything that's still up */
 30.1317 -	/* The event thread should be done, so we can touch SDL_Display */
 30.1318 -	D(bug("CGX_VideoQuit\n"));
 30.1319 -
 30.1320 -	if ( SDL_Display != NULL ) {
 30.1321 -		/* Clean up OpenGL */
 30.1322 -		if(this->gl_data->gl_active == 1) {
 30.1323 -			CGX_GL_Quit(this);
 30.1324 -		}
 30.1325 -		/* Start shutting down the windows */
 30.1326 -		D(bug("Destroying image...\n"));
 30.1327 -		CGX_DestroyImage(this, this->screen);
 30.1328 -		D(bug("Destroying window...\n"));
 30.1329 -		CGX_DestroyWindow(this, this->screen);
 30.1330 -// Otherwise SDL_VideoQuit will try to free it!
 30.1331 -		SDL_VideoSurface=NULL;
 30.1332 -
 30.1333 -		CGX_FreeVideoModes(this);
 30.1334 -
 30.1335 -		/* Free that blank cursor */
 30.1336 -		if ( SDL_BlankCursor != NULL ) {
 30.1337 -			FreeMem(SDL_BlankCursor,16);
 30.1338 -			SDL_BlankCursor = NULL;
 30.1339 -		}
 30.1340 -
 30.1341 -		/* Close the X11 graphics connection */
 30.1342 -		this->hidden->same_format=0;
 30.1343 -
 30.1344 -		D(bug("Destroying screen...\n"));
 30.1345 -
 30.1346 -		if ( GFX_Display != NULL )
 30.1347 -			DestroyScreen(this);
 30.1348 -
 30.1349 -		/* Close the X11 display connection */
 30.1350 -		SDL_Display = NULL;
 30.1351 -
 30.1352 -		/* Unload GL library after X11 shuts down */
 30.1353 -	}
 30.1354 -
 30.1355 -	D(bug("Closing libraries...\n"));
 30.1356 -
 30.1357 -	if( CyberGfxBase) {
 30.1358 -		CloseLibrary(CyberGfxBase);
 30.1359 -		CyberGfxBase=NULL;
 30.1360 -	}
 30.1361 -
 30.1362 -	if (IntuitionBase) {
 30.1363 -		CloseLibrary((struct Library *)IntuitionBase);
 30.1364 -		IntuitionBase=NULL;
 30.1365 -	}
 30.1366 -	if (GfxBase) {
 30.1367 -		CloseLibrary((struct Library *)GfxBase);
 30.1368 -		GfxBase=NULL;
 30.1369 -	}
 30.1370 -
 30.1371 -	if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
 30.1372 -		/* Direct screen access, no memory buffer */
 30.1373 -		this->screen->pixels = NULL;
 30.1374 -	}
 30.1375 -	D(bug("End of CGX_VideoQuit.\n"));
 30.1376 -
 30.1377 -}
 30.1378 -
    31.1 --- a/src/video/cybergfx/SDL_cgxvideo.h	Sun Oct 29 03:44:25 2006 +0000
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,172 +0,0 @@
    31.4 -/*
    31.5 -    SDL - Simple DirectMedia Layer
    31.6 -    Copyright (C) 1997-2006 Sam Lantinga
    31.7 -
    31.8 -    This library is free software; you can redistribute it and/or
    31.9 -    modify it under the terms of the GNU Lesser General Public
   31.10 -    License as published by the Free Software Foundation; either
   31.11 -    version 2.1 of the License, or (at your option) any later version.
   31.12 -
   31.13 -    This library is distributed in the hope that it will be useful,
   31.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   31.16 -    Lesser General Public License for more details.
   31.17 -
   31.18 -    You should have received a copy of the GNU Lesser General Public
   31.19 -    License along with this library; if not, write to the Free Software
   31.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   31.21 -
   31.22 -    Sam Lantinga
   31.23 -    slouken@libsdl.org
   31.24 -*/
   31.25 -#include "SDL_config.h"
   31.26 -
   31.27 -#ifndef _SDL_cgxvideo_h
   31.28 -#define _SDL_cgxvideo_h
   31.29 -
   31.30 -
   31.31 -#include <exec/exec.h>
   31.32 -#include <cybergraphx/cybergraphics.h>
   31.33 -#include <graphics/scale.h>
   31.34 -#include <graphics/gfx.h>
   31.35 -#include <intuition/intuition.h>
   31.36 -#if defined(__SASC) || defined(STORMC4_WOS)
   31.37 -#include <proto/exec.h>
   31.38 -#include <proto/cybergraphics.h>
   31.39 -#include <proto/graphics.h>
   31.40 -#include <proto/intuition.h>
   31.41 -#include <proto/console.h>
   31.42 -#else
   31.43 -#include <inline/exec.h>
   31.44 -#include <inline/cybergraphics.h>
   31.45 -#include <inline/graphics.h>
   31.46 -#include <inline/intuition.h>
   31.47 -#include <inline/console.h>
   31.48 -#endif
   31.49 -
   31.50 -#include "SDL_mouse.h"
   31.51 -#include "../SDL_sysvideo.h"
   31.52 -#include "mydebug.h"
   31.53 -
   31.54 -#define USE_CGX_WRITELUTPIXEL
   31.55 -
   31.56 -/* Hidden "this" pointer for the video functions */
   31.57 -#define _THIS	SDL_VideoDevice *this
   31.58 -
   31.59 -/* Private display data */
   31.60 -struct SDL_PrivateVideoData {
   31.61 -    struct Screen *Public_Display; /* Used for events and window management */
   31.62 -    struct Screen *GFX_Display;	/* Used for graphics and colormap stuff */
   31.63 -    Uint32 SDL_VisualUnused;		/* The visual used by our window */
   31.64 -    struct Window *SDL_Window;	/* Shared by both displays (no X security?) */
   31.65 -    unsigned char *BlankCursor;	/* The invisible cursor */
   31.66 -
   31.67 -    char *SDL_windowid;		/* Flag: true if we have been passed a window */
   31.68 -
   31.69 -    /* The variables used for displaying graphics */
   31.70 -    Uint8 *Ximage;		/* The X image for our window */
   31.71 -    int swap_pixels;		/* Flag: true if display is swapped endian */
   31.72 -
   31.73 -    /* Support for internal mouse warping */
   31.74 -    struct {
   31.75 -        int x;
   31.76 -        int y;
   31.77 -    } mouse_last;
   31.78 -    struct {
   31.79 -        int numerator;
   31.80 -        int denominator;
   31.81 -        int threshold;
   31.82 -    } mouse_accel;
   31.83 -    int mouse_relative;
   31.84 -
   31.85 -    /* The current list of available video modes */
   31.86 -    SDL_Rect **modelist;
   31.87 -
   31.88 -    /* available visuals of interest to us, sorted deepest first */
   31.89 -    struct {
   31.90 -		Uint32 visual;
   31.91 -		int depth;		/* number of significant bits/pixel */
   31.92 -		int bpp;		/* pixel quantum in bits */
   31.93 -    } visuals[5];		/* at most entries for 8, 15, 16, 24 */
   31.94 -    int nvisuals;
   31.95 -
   31.96 -    Uint32 vis;		/* current visual in use */
   31.97 -    int depth;			/* current visual depth (not bpp) */
   31.98 -    int BytesPerPixel;
   31.99 -    int currently_fullscreen,same_format,dbuffer;
  31.100 -
  31.101 -    /* Automatic mode switching support (entering/leaving fullscreen) */
  31.102 -    Uint32 switch_waiting;
  31.103 -    Uint32 switch_time;
  31.104 -
  31.105 -    /* Prevent too many XSync() calls */
  31.106 -    int blit_queued;
  31.107 -
  31.108 -    /* Colormap handling */
  31.109 -    LONG Pens;
  31.110 -    Sint32 *XPixels;		/* A list of pixels that have been allocated, the size depends on the screen format */
  31.111 -	struct ScreenBuffer *SB[2];
  31.112 -	struct RastPort *RP;
  31.113 -    short *iconcolors;		/* List of colors used by the icon */
  31.114 -};
  31.115 -
  31.116 -/* Old variable names */
  31.117 -#define local_X11		(this->hidden->local_X11)
  31.118 -#define SDL_Display		(this->hidden->Public_Display)
  31.119 -#define GFX_Display		(this->hidden->GFX_Display)
  31.120 -#define SDL_Screen		DefaultScreen(this->hidden->Public_Display)
  31.121 -
  31.122 -#define SDL_Visual		(this->hidden->vis)
  31.123 -
  31.124 -#define SDL_Root		RootWindow(SDL_Display, SDL_Screen)
  31.125 -#define WMwindow		(this->hidden->WMwindow)
  31.126 -#define FSwindow		(this->hidden->FSwindow)
  31.127 -#define SDL_Window		(this->hidden->SDL_Window)
  31.128 -#define WM_DELETE_WINDOW	(this->hidden->WM_DELETE_WINDOW)
  31.129 -#define SDL_BlankCursor		(this->hidden->BlankCursor)
  31.130 -#define SDL_windowid		(this->hidden->SDL_windowid)
  31.131 -#define SDL_Ximage		(this->hidden->Ximage)
  31.132 -#define SDL_GC			(this->hidden->gc)
  31.133 -#define swap_pixels		(this->hidden->swap_pixels)
  31.134 -#define mouse_last		(this->hidden->mouse_last)
  31.135 -#define mouse_accel		(this->hidden->mouse_accel)
  31.136 -#define mouse_relative		(this->hidden->mouse_relative)
  31.137 -#define SDL_modelist		(this->hidden->modelist)
  31.138 -#define SDL_RastPort		(this->hidden->RP)
  31.139 -#define saved_mode		(this->hidden->saved_mode)
  31.140 -#define saved_view		(this->hidden->saved_view)
  31.141 -#define currently_fullscreen	(this->hidden->currently_fullscreen)
  31.142 -#define blit_queued		(this->hidden->blit_queued)
  31.143 -#define SDL_DisplayColormap	(this->hidden->GFX_Display->ViewPort.ColorMap)
  31.144 -#define SDL_XPixels		(this->hidden->XPixels)
  31.145 -#define SDL_iconcolors		(this->hidden->iconcolors)
  31.146 -
  31.147 -/* Used to get the X cursor from a window-manager specific cursor */
  31.148 -// extern Cursor SDL_GetWMXCursor(WMcursor *cursor);
  31.149 -
  31.150 -extern int CGX_CreateWindow(_THIS, SDL_Surface *screen,
  31.151 -			    int w, int h, int bpp, Uint32 flags);
  31.152 -extern int CGX_ResizeWindow(_THIS,
  31.153 -			SDL_Surface *screen, int w, int h, Uint32 flags);
  31.154 -
  31.155 -extern void CGX_DestroyWindow(_THIS, SDL_Surface *screen);
  31.156 -
  31.157 -extern struct Library *CyberGfxBase;
  31.158 -extern struct IntuitionBase *IntuitionBase;
  31.159 -extern struct GfxBase *GfxBase;
  31.160 -extern struct ExecBase *SysBase;
  31.161 -extern struct DosLibrary *DOSBase;
  31.162 -
  31.163 -struct private_hwdata
  31.164 -{
  31.165 -	struct BitMap *bmap;
  31.166 -	APTR lock;
  31.167 -	struct SDL_VideoDevice *videodata;
  31.168 -	APTR mask;
  31.169 -	int allocated;
  31.170 -};
  31.171 -
  31.172 -int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst);
  31.173 -int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color);
  31.174 -int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key);
  31.175 -#endif /* _SDL_x11video_h */
    32.1 --- a/src/video/cybergfx/SDL_cgxwm.c	Sun Oct 29 03:44:25 2006 +0000
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,63 +0,0 @@
    32.4 -/*
    32.5 -    SDL - Simple DirectMedia Layer
    32.6 -    Copyright (C) 1997-2006 Sam Lantinga
    32.7 -
    32.8 -    This library is free software; you can redistribute it and/or
    32.9 -    modify it under the terms of the GNU Lesser General Public
   32.10 -    License as published by the Free Software Foundation; either
   32.11 -    version 2.1 of the License, or (at your option) any later version.
   32.12 -
   32.13 -    This library is distributed in the hope that it will be useful,
   32.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   32.16 -    Lesser General Public License for more details.
   32.17 -
   32.18 -    You should have received a copy of the GNU Lesser General Public
   32.19 -    License along with this library; if not, write to the Free Software
   32.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   32.21 -
   32.22 -    Sam Lantinga
   32.23 -    slouken@libsdl.org
   32.24 -*/
   32.25 -#include "SDL_config.h"
   32.26 -
   32.27 -#include "SDL_version.h"
   32.28 -#include "SDL_timer.h"
   32.29 -#include "SDL_video.h"
   32.30 -#include "SDL_syswm.h"
   32.31 -#include "../../events/SDL_events_c.h"
   32.32 -#include "../SDL_pixels_c.h"
   32.33 -#include "SDL_cgxmodes_c.h"
   32.34 -#include "SDL_cgxwm_c.h"
   32.35 -
   32.36 -/* This is necessary for working properly with Enlightenment, etc. */
   32.37 -#define USE_ICON_WINDOW
   32.38 -
   32.39 -void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
   32.40 -{
   32.41 -/* Not yet implemented */
   32.42 -}
   32.43 -
   32.44 -void CGX_SetCaption(_THIS, const char *title, const char *icon)
   32.45 -{
   32.46 -	if(SDL_Window)
   32.47 -		SetWindowTitles(SDL_Window,(char *)title,NULL);
   32.48 -}
   32.49 -
   32.50 -/* Iconify the window */
   32.51 -int CGX_IconifyWindow(_THIS)
   32.52 -{
   32.53 -/* Not yet implemented */
   32.54 -	return 0;
   32.55 -}
   32.56 -
   32.57 -int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info)
   32.58 -{
   32.59 -	if ( info->version.major <= SDL_MAJOR_VERSION ) {
   32.60 -		return(1);
   32.61 -	} else {
   32.62 -		SDL_SetError("Application not compiled with SDL %d.%d\n",
   32.63 -					SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   32.64 -		return(-1);
   32.65 -	}
   32.66 -}
    33.1 --- a/src/video/cybergfx/SDL_cgxwm_c.h	Sun Oct 29 03:44:25 2006 +0000
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,33 +0,0 @@
    33.4 -/*
    33.5 -    SDL - Simple DirectMedia Layer
    33.6 -    Copyright (C) 1997-2006 Sam Lantinga
    33.7 -
    33.8 -    This library is free software; you can redistribute it and/or
    33.9 -    modify it under the terms of the GNU Lesser General Public
   33.10 -    License as published by the Free Software Foundation; either
   33.11 -    version 2.1 of the License, or (at your option) any later version.
   33.12 -
   33.13 -    This library is distributed in the hope that it will be useful,
   33.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   33.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   33.16 -    Lesser General Public License for more details.
   33.17 -
   33.18 -    You should have received a copy of the GNU Lesser General Public
   33.19 -    License along with this library; if not, write to the Free Software
   33.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   33.21 -
   33.22 -    Sam Lantinga
   33.23 -    slouken@libsdl.org
   33.24 -*/
   33.25 -#include "SDL_config.h"
   33.26 -
   33.27 -#include "SDL_cgxvideo.h"
   33.28 -
   33.29 -/* Functions to be exported */
   33.30 -extern void CGX_SetCaption(_THIS, const char *title, const char *icon);
   33.31 -extern void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
   33.32 -extern int CGX_IconifyWindow(_THIS);
   33.33 -extern SDL_GrabMode CGX_GrabInputNoLock(_THIS, SDL_GrabMode mode);
   33.34 -extern SDL_GrabMode CGX_GrabInput(_THIS, SDL_GrabMode mode);
   33.35 -extern int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info);
   33.36 -
    34.1 --- a/test/testplatform.c	Sun Oct 29 03:44:25 2006 +0000
    34.2 +++ b/test/testplatform.c	Sun Oct 29 03:58:27 2006 +0000
    34.3 @@ -154,8 +154,6 @@
    34.4  		printf("This system is running %s\n",
    34.5  #if __AIX__
    34.6  			"AIX"
    34.7 -#elif __AMIGA__
    34.8 -			"AmigaOS"
    34.9  #elif __BEOS__
   34.10  			"BeOS"
   34.11  #elif __BSDI__