Updated the Amiga OS port of SDL (thanks Gabriele)
authorSam Lantinga <slouken@lokigames.com>
Thu, 10 May 2001 20:13:29 +0000
changeset 2175a95f82bc1f
parent 20 3dc008dc229d
child 22 48c34d68918e
Updated the Amiga OS port of SDL (thanks Gabriele)
BUGS
README.AmigaOS
configure.in
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
src/audio/amigaos/Makefile.am
src/audio/amigaos/SDL_ahiaudio.c
src/audio/amigaos/SDL_ahiaudio.h
src/audio/amigaos/SDL_audio.c
src/audio/amigaos/SDL_lowaudio.h
src/audio/amigaos/SDL_sysaudio.h
src/joystick/amigaos/Makefile.am
src/joystick/amigaos/SDL_sysjoystick.c
src/thread/amigaos/SDL_syssem.c
src/thread/amigaos/SDL_systhread.c
src/thread/amigaos/SDL_thread.c
src/timer/amigaos/SDL_systimer.c
src/video/cybergfx/SDL_amigaevents.c
src/video/cybergfx/SDL_cgxaccel.c
src/video/cybergfx/SDL_cgximage.c
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_cgxyuv.c
src/video/cybergfx/SDL_cgxyuv_c.h
src/video/default_cursor.h
     1.1 --- a/BUGS	Thu May 10 20:10:54 2001 +0000
     1.2 +++ b/BUGS	Thu May 10 20:13:29 2001 +0000
     1.3 @@ -169,9 +169,6 @@
     1.4   
     1.5  	The software surfaces could use some speed up.
     1.6   
     1.7 -	Many of the test apps segment violate on exit, and I'm not sure
     1.8 -	they're all working either
     1.9 - 
    1.10  	It doesn't look like the OpenGL stuff is there. (did a grep for
    1.11  	PdCreateOpenGLContext, nothing found).
    1.12   
    1.13 @@ -187,13 +184,4 @@
    1.14  
    1.15  	Continuous relative mouse motion is not implemented.
    1.16  
    1.17 -	Audio can work, but isn't completely integrated in the CVS
    1.18 -	version of SDL.
    1.19 -
    1.20 -	The joystick subsystem isn't implemented yet.
    1.21 -
    1.22 -	There's some confusion about the multi-threaded synchronization
    1.23 -	primitives on AmigaOS, so mutexes and semaphores aren't correctly
    1.24 -	implemented yet.
    1.25 -
    1.26  	The AmigaOS port was done by Gabriele.Greco@galactica.it
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/README.AmigaOS	Thu May 10 20:13:29 2001 +0000
     2.3 @@ -0,0 +1,50 @@
     2.4 +This is the porting of 1.2.0 version of SDL (the latest stable one)
     2.5 +to AmigaOS/68k.
     2.6 +
     2.7 +All the bugs known of the past version have been corrected. And I've
     2.8 +added all the new SDL features.
     2.9 +
    2.10 +This version of SDL needs Cybergraphx V3 (r69+) or CyberGraphX V4
    2.11 +and AHI v3+. Probably it works also with P96 or CGXAga, but it's 
    2.12 +untested.
    2.13 +
    2.14 +This version is available as linked library for SAS/C and GCC, only 68k this 
    2.15 +time, a powerup (ppcemu compatible) and a morphos version will be ready quite 
    2.16 +soon (i hope).
    2.17 +
    2.18 +Implemented:
    2.19 +
    2.20 +- 8/16/24/32bit video modes, both fullscreen and windowed.
    2.21 +- Hardware surfaces.
    2.22 +- CGX blitting acceleration.
    2.23 +- CGX colorkey blitting acceleration.
    2.24 +- AHI audio (8/16 bit, with any audio format), always uses unit 0 for now.
    2.25 +- Thread support (maybe not 100% compatible with other implementations)
    2.26 +- Semaphores 
    2.27 +- Window resizing and backdrop windows (NEW)
    2.28 +- Joystick/Joypad support.
    2.29 +
    2.30 +To do:
    2.31 +
    2.32 +- CDRom audio playing support
    2.33 +- OpenGL (A guy was working on it but I've lost his tracks :( )
    2.34 +
    2.35 +The SAS/C library is distributed with debug info attached, to strip debug info 
    2.36 +simply add STRIPDEBUG argument to the linker.
    2.37 +
    2.38 +NOTE: SDL includes debug output using kprintf, to disable it add to your 
    2.39 +project a function like this:
    2.40 +
    2.41 +void kprintf(char *a,...)
    2.42 +{
    2.43 +}
    2.44 +
    2.45 +Otherwise you can redirect the debug to a console window with sushi, sashimi or
    2.46 +similar tools (the default output is the internal serial port). 
    2.47 +
    2.48 +For info, support, bugfix and other feel free to mail me:
    2.49 +
    2.50 +Gabriele Greco (gabriele.greco@aruba.it)
    2.51 +
    2.52 +You can find also a small SDL Amiga page at:
    2.53 +http://ggreco.interfree.it/sdl.html
     3.1 --- a/configure.in	Thu May 10 20:10:54 2001 +0000
     3.2 +++ b/configure.in	Thu May 10 20:13:29 2001 +0000
     3.3 @@ -1936,6 +1936,7 @@
     3.4  src/video/dummy/Makefile
     3.5  src/events/Makefile
     3.6  src/joystick/Makefile
     3.7 +src/joystick/amigaos/Makefile
     3.8  src/joystick/beos/Makefile
     3.9  src/joystick/dummy/Makefile
    3.10  src/joystick/linux/Makefile
     4.1 --- a/src/audio/SDL_audio.c	Thu May 10 20:10:54 2001 +0000
     4.2 +++ b/src/audio/SDL_audio.c	Thu May 10 20:13:29 2001 +0000
     4.3 @@ -76,6 +76,10 @@
     4.4  #ifdef _AIX
     4.5  	&Paud_bootstrap,
     4.6  #endif
     4.7 +#ifdef ENABLE_AHI
     4.8 +	&AHI_bootstrap,
     4.9 +#endif
    4.10 +
    4.11  	NULL
    4.12  };
    4.13  SDL_AudioDevice *current_audio = NULL;
    4.14 @@ -84,6 +88,9 @@
    4.15  int SDL_AudioInit(const char *driver_name);
    4.16  void SDL_AudioQuit(void);
    4.17  
    4.18 +#ifdef ENABLE_AHI
    4.19 +static int audio_configured = 0;
    4.20 +#endif
    4.21  
    4.22  /* The general mixing thread function */
    4.23  int SDL_RunAudio(void *audiop)
    4.24 @@ -94,6 +101,21 @@
    4.25  	void  *udata;
    4.26  	void (*fill)(void *userdata,Uint8 *stream, int len);
    4.27  	int    silence;
    4.28 +#ifdef ENABLE_AHI
    4.29 +	int started = 0;
    4.30 +
    4.31 +/* AmigaOS NEEDS that the audio driver is opened in the thread that uses it! */
    4.32 +
    4.33 +	D(bug("Task audio started audio struct:<%lx>...\n",audiop));
    4.34 +
    4.35 +	D(bug("Before Openaudio..."));
    4.36 +	if(audio->OpenAudio(audio, &audio->spec)==-1)
    4.37 +	{
    4.38 +		D(bug("Open audio failed...\n"));
    4.39 +		return(-1);
    4.40 +	}
    4.41 +	D(bug("OpenAudio...OK\n"));
    4.42 +#endif
    4.43  
    4.44  	/* Perform any thread setup */
    4.45  	if ( audio->ThreadInit ) {
    4.46 @@ -104,6 +126,15 @@
    4.47  	/* Set up the mixing function */
    4.48  	fill  = audio->spec.callback;
    4.49  	udata = audio->spec.userdata;
    4.50 +
    4.51 +#ifdef ENABLE_AHI
    4.52 +	audio_configured = 1;
    4.53 +
    4.54 +	D(bug("Audio configured... Checking for conversion\n"));
    4.55 +	SDL_mutexP(audio->mixer_lock);
    4.56 +	D(bug("Semaphore obtained...\n"));
    4.57 +#endif
    4.58 +
    4.59  	if ( audio->convert.needed ) {
    4.60  		if ( audio->convert.src_format == AUDIO_U8 ) {
    4.61  			silence = 0x80;
    4.62 @@ -117,6 +148,12 @@
    4.63  	}
    4.64  	stream = audio->fake_stream;
    4.65  
    4.66 +#ifdef ENABLE_AHI
    4.67 +	SDL_mutexV(audio->mixer_lock);
    4.68 +	D(bug("Entering audio loop...\n"));
    4.69 +#endif
    4.70 +
    4.71 +
    4.72  	/* Loop, filling the audio buffers */
    4.73  	while ( audio->enabled ) {
    4.74  
    4.75 @@ -124,12 +161,14 @@
    4.76  		if ( stream == audio->fake_stream ) {
    4.77  			SDL_Delay((audio->spec.samples*1000)/audio->spec.freq);
    4.78  		} else {
    4.79 +#ifdef ENABLE_AHI
    4.80 +			if ( started > 1 )
    4.81 +#endif
    4.82  			audio->WaitAudio(audio);
    4.83  		}
    4.84  
    4.85  		/* Fill the current buffer with sound */
    4.86  		if ( audio->convert.needed ) {
    4.87 -			/* The buffer may not be allocated yet */
    4.88  			if ( audio->convert.buf ) {
    4.89  				stream = audio->convert.buf;
    4.90  			} else {
    4.91 @@ -163,12 +202,25 @@
    4.92  		/* Ready current buffer for play and change current buffer */
    4.93  		if ( stream != audio->fake_stream ) {
    4.94  			audio->PlayAudio(audio);
    4.95 +#ifdef ENABLE_AHI
    4.96 +/* AmigaOS don't have to wait the first time audio is played! */
    4.97 +			started++;
    4.98 +#endif
    4.99  		}
   4.100  	}
   4.101  	/* Wait for the audio to drain.. */
   4.102  	if ( audio->WaitDone ) {
   4.103  		audio->WaitDone(audio);
   4.104  	}
   4.105 +
   4.106 +#ifdef ENABLE_AHI
   4.107 +	D(bug("WaitAudio...Done\n"));
   4.108 +
   4.109 +	audio->CloseAudio(audio);
   4.110 +
   4.111 +	D(bug("CloseAudio..Done, subtask exiting...\n"));
   4.112 +	audio_configured = 0;
   4.113 +#endif
   4.114  	return(0);
   4.115  }
   4.116  
   4.117 @@ -312,11 +364,33 @@
   4.118  	audio->convert.needed = 0;
   4.119  	audio->enabled = 1;
   4.120  	audio->paused  = 1;
   4.121 +
   4.122 +#ifndef ENABLE_AHI
   4.123 +
   4.124 +/* AmigaOS opens audio inside the main loop */
   4.125  	audio->opened = audio->OpenAudio(audio, &audio->spec)+1;
   4.126 +
   4.127  	if ( ! audio->opened ) {
   4.128  		SDL_CloseAudio();
   4.129  		return(-1);
   4.130  	}
   4.131 +#else
   4.132 +	D(bug("Locking semaphore..."));
   4.133 +	SDL_mutexP(audio->mixer_lock);
   4.134 +
   4.135 +	audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
   4.136 +	D(bug("Created thread...\n"));
   4.137 +
   4.138 +	if ( audio->thread == NULL ) {
   4.139 +		SDL_mutexV(audio->mixer_lock);
   4.140 +		SDL_CloseAudio();
   4.141 +		SDL_SetError("Couldn't create audio thread");
   4.142 +		return(-1);
   4.143 +	}
   4.144 +
   4.145 +	while(!audio_configured)
   4.146 +		SDL_Delay(100);
   4.147 +#endif
   4.148  
   4.149  	/* If the audio driver changes the buffer size, accept it */
   4.150  	if ( audio->spec.samples != desired->samples ) {
   4.151 @@ -365,6 +439,7 @@
   4.152  		}
   4.153  	}
   4.154  
   4.155 +#ifndef ENABLE_AHI
   4.156  	/* Start the audio thread if necessary */
   4.157  	switch (audio->opened) {
   4.158  		case  1:
   4.159 @@ -381,6 +456,12 @@
   4.160  			/* The audio is now playing */
   4.161  			break;
   4.162  	}
   4.163 +#else
   4.164 +	SDL_mutexV(audio->mixer_lock);
   4.165 +	D(bug("SDL_OpenAudio USCITA...\n"));
   4.166 +
   4.167 +#endif
   4.168 +
   4.169  	return(0);
   4.170  }
   4.171  
   4.172 @@ -457,12 +538,14 @@
   4.173  		}
   4.174  		if ( audio->convert.needed ) {
   4.175  			SDL_FreeAudioMem(audio->convert.buf);
   4.176 +
   4.177  		}
   4.178 +#ifndef ENABLE_AHI
   4.179  		if ( audio->opened ) {
   4.180  			audio->CloseAudio(audio);
   4.181  			audio->opened = 0;
   4.182  		}
   4.183 -
   4.184 +#endif
   4.185  		/* Free the driver data */
   4.186  		audio->free(audio);
   4.187  		current_audio = NULL;
     5.1 --- a/src/audio/SDL_sysaudio.h	Thu May 10 20:10:54 2001 +0000
     5.2 +++ b/src/audio/SDL_sysaudio.h	Thu May 10 20:13:29 2001 +0000
     5.3 @@ -126,14 +126,17 @@
     5.4  #ifdef ENABLE_WINDIB
     5.5  extern AudioBootStrap WAVEOUT_bootstrap;
     5.6  #endif
     5.7 +#ifdef _AIX
     5.8 +extern AudioBootStrap Paud_bootstrap;
     5.9 +#endif
    5.10  #ifdef __BEOS__
    5.11  extern AudioBootStrap BAUDIO_bootstrap;
    5.12  #endif
    5.13  #if defined(macintosh) || TARGET_API_MAC_CARBON
    5.14  extern AudioBootStrap SNDMGR_bootstrap;
    5.15  #endif
    5.16 -#ifdef _AIX
    5.17 -extern AudioBootStrap Paud_bootstrap;
    5.18 +#ifdef ENABLE_AHI
    5.19 +extern AudioBootStrap AHI_bootstrap;
    5.20  #endif
    5.21  
    5.22  /* This is the current audio device */
     6.1 --- a/src/audio/amigaos/Makefile.am	Thu May 10 20:10:54 2001 +0000
     6.2 +++ b/src/audio/amigaos/Makefile.am	Thu May 10 20:13:29 2001 +0000
     6.3 @@ -3,6 +3,6 @@
     6.4  
     6.5  noinst_LTLIBRARIES = libaudio_arch.la
     6.6  
     6.7 -ARCH_SRCS = SDL_ahiaudio.c SDL_audio.c SDL_lowaudio.h SDL_sysaudio.h
     6.8 +ARCH_SRCS = SDL_ahiaudio.c SDL_ahiaudio.h
     6.9  
    6.10  libaudio_arch_la_SOURCES = $(ARCH_SRCS)
     7.1 --- a/src/audio/amigaos/SDL_ahiaudio.c	Thu May 10 20:10:54 2001 +0000
     7.2 +++ b/src/audio/amigaos/SDL_ahiaudio.c	Thu May 10 20:13:29 2001 +0000
     7.3 @@ -27,13 +27,17 @@
     7.4   "@(#) $Id$";
     7.5  #endif
     7.6  
     7.7 -/* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */
     7.8 +/* Allow access to a raw mixing buffer (for AmigaOS) */
     7.9 +
    7.10 +#include <stdio.h>
    7.11 +#include <stdlib.h>
    7.12 +#include <string.h>
    7.13  
    7.14  #include "SDL_endian.h"
    7.15  #include "SDL_audio.h"
    7.16  #include "SDL_audiomem.h"
    7.17  #include "SDL_audio_c.h"
    7.18 -#include "SDL_lowaudio.h"
    7.19 +#include "SDL_ahiaudio.h"
    7.20  
    7.21  /* Audio driver functions */
    7.22  static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec);
    7.23 @@ -54,11 +58,29 @@
    7.24  
    7.25  static int Audio_Available(void)
    7.26  {
    7.27 -#ifndef NO_AMIGADEBUG
    7.28 -	D(bug("AHI available.\n"));
    7.29 -#endif
    7.30 +	int ok=0;
    7.31 +	struct MsgPort *p;
    7.32 +	struct AHIRequest *req;
    7.33  
    7.34 -	return 1;
    7.35 +	if(p=CreateMsgPort())
    7.36 +	{
    7.37 +		if(req=(struct AHIRequest *)CreateIORequest(p,sizeof(struct AHIRequest)))
    7.38 +		{
    7.39 +			req->ahir_Version=4;
    7.40 +
    7.41 +			if(!OpenDevice(AHINAME,0,(struct IORequest *)req,NULL))
    7.42 +			{
    7.43 +				D(bug("AHI available.\n"));
    7.44 +				ok=1;
    7.45 +				CloseDevice((struct IORequest *)req);
    7.46 +			}
    7.47 +			DeleteIORequest((struct IORequest *)req);
    7.48 +		}
    7.49 +		DeleteMsgPort(p);
    7.50 +	}
    7.51 +
    7.52 +	D(if(!ok) bug("AHI not available\n"));
    7.53 +	return ok;
    7.54  }
    7.55  
    7.56  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    7.57 @@ -125,7 +147,7 @@
    7.58  	/* Write the audio data out */
    7.59  	audio_req[current_buffer] -> ahir_Std. io_Message.mn_Node.ln_Pri = 60;
    7.60  	audio_req[current_buffer] -> ahir_Std. io_Data                = mixbuf[current_buffer];
    7.61 -	audio_req[current_buffer] -> ahir_Std. io_Length              = this->spec.samples*this->hidden->bytespersample;
    7.62 +	audio_req[current_buffer] -> ahir_Std. io_Length              = this->hidden->size;
    7.63  	audio_req[current_buffer] -> ahir_Std. io_Offset              = 0;
    7.64  	audio_req[current_buffer] -> ahir_Std . io_Command            = CMD_WRITE;
    7.65  	audio_req[current_buffer] -> ahir_Frequency                   = this->hidden->freq;
    7.66 @@ -149,42 +171,57 @@
    7.67  {
    7.68  	D(bug("Closing audio...\n"));
    7.69  
    7.70 +	playing=0;
    7.71 +
    7.72 +	if(audio_req[0])
    7.73 +	{
    7.74 +		if(audio_req[1])
    7.75 +		{
    7.76 +			D(bug("Break req[1]...\n"));
    7.77 +
    7.78 +			AbortIO((struct IORequest *)audio_req[1]);
    7.79 +			WaitIO((struct IORequest *)audio_req[1]);
    7.80 +		}
    7.81 +
    7.82 +		D(bug("Break req[0]...\n"));
    7.83 +
    7.84 +		AbortIO((struct IORequest *)audio_req[0]);
    7.85 +		WaitIO((struct IORequest *)audio_req[0]);
    7.86 +
    7.87 +		if(audio_req[1])
    7.88 +		{
    7.89 +			D(bug("Break AGAIN req[1]...\n"));
    7.90 +			AbortIO((struct IORequest *)audio_req[1]);
    7.91 +			WaitIO((struct IORequest *)audio_req[1]);
    7.92 +		}
    7.93 +// Double abort to be sure to break the dbuffering process.
    7.94 +
    7.95 +		SDL_Delay(200);
    7.96 +
    7.97 +		D(bug("Reqs breaked, closing device...\n"));
    7.98 +		CloseDevice((struct IORequest *)audio_req[0]);
    7.99 +		D(bug("Device closed, freeing memory...\n"));
   7.100 +		myfree(audio_req[1]);
   7.101 +		D(bug("Memory freed, deleting IOReq...\n")); 
   7.102 +		DeleteIORequest((struct IORequest *)audio_req[0]);
   7.103 +		audio_req[0]=audio_req[1]=NULL;
   7.104 +	}
   7.105 +
   7.106 +	D(bug("Freeing mixbuf[0]...\n"));
   7.107  	if ( mixbuf[0] != NULL ) {
   7.108  		myfree(mixbuf[0]);
   7.109  //		SDL_FreeAudioMem(mixbuf[0]);
   7.110  		mixbuf[0] = NULL;
   7.111  	}
   7.112  
   7.113 +	D(bug("Freeing mixbuf[1]...\n"));
   7.114  	if ( mixbuf[1] != NULL ) {
   7.115  		myfree(mixbuf[1]);
   7.116  //		SDL_FreeAudioMem(mixbuf[1]);
   7.117  		mixbuf[1] = NULL;
   7.118  	}
   7.119  
   7.120 -	playing=0;
   7.121 -
   7.122 -	if(audio_req[0])
   7.123 -	{
   7.124 -		if(audio_req[1])
   7.125 -		{
   7.126 -			if(!CheckIO((struct IORequest *)audio_req[1]))
   7.127 -			{
   7.128 -				AbortIO((struct IORequest *)audio_req[1]);
   7.129 -				WaitIO((struct IORequest *)audio_req[1]);
   7.130 -			}
   7.131 -			myfree(audio_req[1]);
   7.132 -		}
   7.133 -
   7.134 -		if(!CheckIO((struct IORequest *)audio_req[0]))
   7.135 -		{
   7.136 -			AbortIO((struct IORequest *)audio_req[0]);
   7.137 -			WaitIO((struct IORequest *)audio_req[0]);
   7.138 -		}
   7.139 -
   7.140 -		CloseDevice((struct IORequest *)audio_req[0]);
   7.141 -		DeleteIORequest((struct IORequest *)audio_req[0]);
   7.142 -		audio_req[0]=audio_req[1]=NULL;
   7.143 -	}
   7.144 +	D(bug("Freeing audio_port...\n"));
   7.145  
   7.146  	if ( audio_port != NULL ) {
   7.147  		DeleteMsgPort(audio_port);
   7.148 @@ -206,8 +243,10 @@
   7.149  			D(bug("Samples a 8 bit...\n"));
   7.150  			spec->format = AUDIO_S8;
   7.151  			this->hidden->bytespersample=1;
   7.152 -			this->hidden->type = AHIST_M8S;
   7.153 -
   7.154 +			if(spec->channels<2)
   7.155 +				this->hidden->type = AHIST_M8S;
   7.156 +			else
   7.157 +				this->hidden->type = AHIST_S8S;
   7.158  		}
   7.159  		break;
   7.160  
   7.161 @@ -215,7 +254,10 @@
   7.162  			D(bug("Samples a 16 bit...\n"));
   7.163  			spec->format = AUDIO_S16MSB;
   7.164  			this->hidden->bytespersample=2;
   7.165 -			this->hidden->type = AHIST_M16S;
   7.166 +			if(spec->channels<2)
   7.167 +				this->hidden->type = AHIST_M16S;
   7.168 +			else
   7.169 +				this->hidden->type = AHIST_S16S;
   7.170  		}
   7.171  		break;
   7.172  
   7.173 @@ -225,6 +267,13 @@
   7.174  		}
   7.175  	}
   7.176  
   7.177 +	if(spec->channels!=1 && spec->channels!=2)
   7.178 +	{
   7.179 +		D(bug("Wrong channel number!\n"));
   7.180 +		SDL_SetError("Channel number non supported");
   7.181 +		return -1;
   7.182 +	}
   7.183 +
   7.184  	D(bug("Before CalculateAudioSpec\n"));
   7.185  	/* Update the fragment size as size in bytes */
   7.186  	SDL_CalculateAudioSpec(spec);
   7.187 @@ -258,8 +307,9 @@
   7.188  	
   7.189  	D(bug("AFTER opendevice\n"));
   7.190  
   7.191 -	/* Set output frequency */
   7.192 +	/* Set output frequency and size */
   7.193  	this->hidden->freq = spec->freq;
   7.194 +	this->hidden->size = spec->size;
   7.195  
   7.196  	D(bug("Before buffer allocation\n"));
   7.197  
   7.198 @@ -292,7 +342,7 @@
   7.199  	current_buffer=0;
   7.200  	playing=0;
   7.201  
   7.202 -	D(bug("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld\n",spec->freq,mixbuf[0],mixbuf[1],spec->size,this->hidden->bytespersample*8));
   7.203 +	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));
   7.204  
   7.205  	/* We're ready to rock and roll. :-) */
   7.206  	return(0);
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/audio/amigaos/SDL_ahiaudio.h	Thu May 10 20:13:29 2001 +0000
     8.3 @@ -0,0 +1,63 @@
     8.4 +/*
     8.5 +    SDL - Simple DirectMedia Layer
     8.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     8.7 +
     8.8 +    This library is free software; you can redistribute it and/or
     8.9 +    modify it under the terms of the GNU Library General Public
    8.10 +    License as published by the Free Software Foundation; either
    8.11 +    version 2 of the License, or (at your option) any later version.
    8.12 +
    8.13 +    This library is distributed in the hope that it will be useful,
    8.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 +    Library General Public License for more details.
    8.17 +
    8.18 +    You should have received a copy of the GNU Library General Public
    8.19 +    License along with this library; if not, write to the Free
    8.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    8.21 +
    8.22 +    Sam Lantinga
    8.23 +    slouken@devolution.com
    8.24 +*/
    8.25 +
    8.26 +#ifdef SAVE_RCSID
    8.27 +static char rcsid =
    8.28 + "@(#) $Id$";
    8.29 +#endif
    8.30 +
    8.31 +#ifndef _SDL_ahiaudio_h
    8.32 +#define _SDL_ahiaudio_h
    8.33 +
    8.34 +#include <exec/exec.h>
    8.35 +#include <dos/dos.h>
    8.36 +#ifdef __SASC
    8.37 +#include <proto/exec.h>
    8.38 +#else
    8.39 +#include <inline/exec.h>
    8.40 +#endif
    8.41 +
    8.42 +#include <devices/ahi.h>
    8.43 +#include "mydebug.h"
    8.44 +#include "SDL_sysaudio.h"
    8.45 +
    8.46 +/* Hidden "this" pointer for the audio functions */
    8.47 +#define _THIS	SDL_AudioDevice *this
    8.48 +
    8.49 +struct SDL_PrivateAudioData {
    8.50 +	/* The handle for the audio device */
    8.51 +	struct AHIRequest *audio_req[2];
    8.52 +	struct MsgPort *audio_port;
    8.53 +	Sint32 freq,type,bytespersample;
    8.54 +	Uint8 *mixbuf[2];           /* The app mixing buffer */
    8.55 +	int current_buffer;
    8.56 +	Uint32 playing;
    8.57 +};
    8.58 +
    8.59 +/* Old variable names */
    8.60 +#define audio_port		(this->hidden->audio_port)
    8.61 +#define audio_req		(this->hidden->audio_req)
    8.62 +#define mixbuf			(this->hidden->mixbuf)
    8.63 +#define current_buffer		(this->hidden->current_buffer)
    8.64 +#define playing			(this->hidden->playing)
    8.65 +
    8.66 +#endif /* _SDL_ahiaudio_h */
     9.1 --- a/src/audio/amigaos/SDL_audio.c	Thu May 10 20:10:54 2001 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,532 +0,0 @@
     9.4 -/*
     9.5 -    SDL - Simple DirectMedia Layer
     9.6 -    Copyright (C) 1997, 1998, 1999, 2000, 2001  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 Library General Public
    9.10 -    License as published by the Free Software Foundation; either
    9.11 -    version 2 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 -    Library General Public License for more details.
    9.17 -
    9.18 -    You should have received a copy of the GNU Library General Public
    9.19 -    License along with this library; if not, write to the Free
    9.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    9.21 -
    9.22 -    Sam Lantinga
    9.23 -    slouken@devolution.com
    9.24 -*/
    9.25 -
    9.26 -#ifdef SAVE_RCSID
    9.27 -static char rcsid =
    9.28 - "@(#) $Id$";
    9.29 -#endif
    9.30 -
    9.31 -/* Allow access to a raw mixing buffer */
    9.32 -#include <stdlib.h>
    9.33 -#include <stdio.h>
    9.34 -#include <signal.h>
    9.35 -#include <string.h>
    9.36 -
    9.37 -#include "SDL.h"
    9.38 -#include "SDL_audio.h"
    9.39 -#include "SDL_timer.h"
    9.40 -#include "SDL_error.h"
    9.41 -#include "SDL_audio_c.h"
    9.42 -#include "SDL_audiomem.h"
    9.43 -#include "SDL_sysaudio.h"
    9.44 -
    9.45 -
    9.46 -/* Available audio drivers */
    9.47 -static AudioBootStrap *bootstrap[] = {
    9.48 -#ifdef unix
    9.49 -	&AUDIO_bootstrap,
    9.50 -#endif
    9.51 -#ifdef linux
    9.52 -	&DMA_bootstrap,
    9.53 -#endif
    9.54 -#ifdef ESD_SUPPORT
    9.55 -	&ESD_bootstrap,
    9.56 -#endif
    9.57 -#ifdef ENABLE_DIRECTX
    9.58 -	&DSOUND_bootstrap,
    9.59 -#endif
    9.60 -#ifdef ENABLE_WINDIB
    9.61 -	&WAVEOUT_bootstrap,
    9.62 -#endif
    9.63 -#ifdef __BEOS__
    9.64 -	&BAUDIO_bootstrap,
    9.65 -#endif
    9.66 -#ifdef macintosh
    9.67 -	&AUDIO_bootstrap,
    9.68 -#endif
    9.69 -#ifdef _AIX
    9.70 -	&Paud_bootstrap,
    9.71 -#endif
    9.72 -#ifdef ENABLE_CYBERGRAPHICS
    9.73 -	&AHI_bootstrap,
    9.74 -#endif
    9.75 -	NULL
    9.76 -};
    9.77 -SDL_AudioDevice *current_audio = NULL;
    9.78 -
    9.79 -/* Various local functions */
    9.80 -int SDL_AudioInit(const char *driver_name);
    9.81 -void SDL_AudioQuit(void);
    9.82 -
    9.83 -struct SignalSemaphore AudioSem;
    9.84 -
    9.85 -/* The general mixing thread function */
    9.86 -int RunAudio(void *audiop)
    9.87 -{
    9.88 -	SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop;
    9.89 -	Uint8 *stream;
    9.90 -	int    stream_len;
    9.91 -	void  *udata;
    9.92 -	void (*fill)(void *userdata,Uint8 *stream, int len);
    9.93 -	int    silence,started=0;
    9.94 -
    9.95 -	D(bug("Task audio started audio struct:<%lx>...\n",audiop));
    9.96 -
    9.97 -	D(bug("Before Openaudio..."));
    9.98 -	if(audio->OpenAudio(audio, &audio->spec)==-1)
    9.99 -	{
   9.100 -		return(-1);
   9.101 -	}
   9.102 -
   9.103 -	D(bug("OpenAudio...OK\n"));
   9.104 -
   9.105 -	/* Perform any thread setup */
   9.106 -	if ( audio->ThreadInit ) {
   9.107 -		audio->ThreadInit(audio);
   9.108 -	}
   9.109 -	audio->threadid = SDL_ThreadID();
   9.110 -
   9.111 -	/* Set up the mixing function */
   9.112 -	fill  = audio->spec.callback;
   9.113 -	udata = audio->spec.userdata;
   9.114 -	if ( audio->convert.needed ) {
   9.115 -		if ( audio->convert.src_format == AUDIO_U8 ) {
   9.116 -			silence = 0x80;
   9.117 -			D(bug("*** Silence 0x80 ***\n"));
   9.118 -		} else {
   9.119 -			silence = 0;
   9.120 -		}
   9.121 -		stream_len = audio->convert.len;
   9.122 -	} else {
   9.123 -		silence = audio->spec.silence;
   9.124 -		stream_len = audio->spec.size;
   9.125 -	}
   9.126 -	stream = audio->fake_stream;
   9.127 -
   9.128 -	ObtainSemaphore(&AudioSem);
   9.129 -	ReleaseSemaphore(&AudioSem);
   9.130 -
   9.131 -	D(bug("Enering audio loop...\n"));
   9.132 -
   9.133 -	D(if(audio->convert.needed)bug("*** Conversion needed.\n"));
   9.134 -
   9.135 -	/* Loop, filling the audio buffers */
   9.136 -	while ( audio->enabled ) 
   9.137 -	{
   9.138 -		/* Wait for new current buffer to finish playing */
   9.139 -
   9.140 -		if ( stream == audio->fake_stream )
   9.141 -			SDL_Delay((audio->spec.samples*1000)/audio->spec.freq);
   9.142 -		else
   9.143 -		{
   9.144 -			if(started>1)
   9.145 -			{
   9.146 -//				D(bug("Waiting audio...\n"));
   9.147 -				audio->WaitAudio(audio);
   9.148 -			}
   9.149 -		}
   9.150 -
   9.151 -		ObtainSemaphore(&AudioSem);
   9.152 -
   9.153 -		/* Fill the current buffer with sound */
   9.154 -		if ( audio->convert.needed ) {
   9.155 -			stream = audio->convert.buf;
   9.156 -		} else {
   9.157 -			stream = audio->GetAudioBuf(audio);
   9.158 -		}
   9.159 -
   9.160 -		if(stream!=audio->fake_stream)
   9.161 -			memset(stream, silence, stream_len);
   9.162 -
   9.163 -		if ( ! audio->paused ) {
   9.164 -			ObtainSemaphore(&audio->mixer_lock);
   9.165 -			(*fill)(udata, stream, stream_len);
   9.166 -			ReleaseSemaphore(&audio->mixer_lock);
   9.167 -		}
   9.168 -
   9.169 -		/* Convert the audio if necessary */
   9.170 -		if ( audio->convert.needed ) {
   9.171 -			SDL_ConvertAudio(&audio->convert);
   9.172 -			stream = audio->GetAudioBuf(audio);
   9.173 -			memcpy(stream, audio->convert.buf,audio->convert.len_cvt);
   9.174 -		}
   9.175 -
   9.176 -		if(stream!=audio->fake_stream)
   9.177 -		{
   9.178 -//			D(bug("Playing stream at %lx\n",stream));
   9.179 -
   9.180 -			audio->PlayAudio(audio);
   9.181 -			started++;
   9.182 -		}
   9.183 -		ReleaseSemaphore(&AudioSem);
   9.184 -
   9.185 -	}
   9.186 -	D(bug("Out of subtask loop...\n"));
   9.187 -
   9.188 -	/* Wait for the audio to drain.. */
   9.189 -	if ( audio->WaitDone ) {
   9.190 -		audio->WaitDone(audio);
   9.191 -	}
   9.192 -
   9.193 -	D(bug("WaitAudio...Done\n"));
   9.194 -
   9.195 -	audio->CloseAudio(audio);
   9.196 -
   9.197 -	D(bug("CloseAudio..Done, subtask exiting...\n"));
   9.198 -
   9.199 -	return(0);
   9.200 -}
   9.201 -
   9.202 -int SDL_AudioInit(const char *driver_name)
   9.203 -{
   9.204 -	SDL_AudioDevice *audio;
   9.205 -	int i = 0, idx;
   9.206 -
   9.207 -	/* Check to make sure we don't overwrite 'current_audio' */
   9.208 -	if ( current_audio != NULL ) {
   9.209 -		SDL_AudioQuit();
   9.210 -	}
   9.211 -
   9.212 -	/* Select the proper audio driver */
   9.213 -	audio = NULL;
   9.214 -	idx = 0;
   9.215 -
   9.216 -	InitSemaphore(&AudioSem);
   9.217 -
   9.218 -	if ( audio == NULL ) {
   9.219 -		if ( driver_name != NULL ) {
   9.220 -			if ( strrchr(driver_name, ':') != NULL ) {
   9.221 -				idx = atoi(strrchr(driver_name, ':')+1);
   9.222 -			}
   9.223 -			for ( i=0; bootstrap[i]; ++i ) {
   9.224 -				if (strncmp(bootstrap[i]->name, driver_name,
   9.225 -				            strlen(bootstrap[i]->name)) == 0) {
   9.226 -					if ( bootstrap[i]->available() ) {
   9.227 -						audio=bootstrap[i]->create(idx);
   9.228 -						break;
   9.229 -					}
   9.230 -				}
   9.231 -			}
   9.232 -		} else {
   9.233 -			for ( i=0; bootstrap[i]; ++i ) {
   9.234 -				if ( bootstrap[i]->available() ) {
   9.235 -					audio = bootstrap[i]->create(idx);
   9.236 -					if ( audio != NULL ) {
   9.237 -						break;
   9.238 -					}
   9.239 -				}
   9.240 -			}
   9.241 -		}
   9.242 -		if ( audio == NULL ) {
   9.243 -			SDL_SetError("No available audio device");
   9.244 -#if 0 /* Don't fail SDL_Init() if audio isn't available.
   9.245 -         SDL_OpenAudio() will handle it at that point.  *sigh*
   9.246 -       */
   9.247 -			return(-1);
   9.248 -#endif
   9.249 -		}
   9.250 -	}
   9.251 -	current_audio = audio;
   9.252 -	if ( current_audio ) {
   9.253 -		current_audio->name = bootstrap[i]->name;
   9.254 -	}
   9.255 -	return(0);
   9.256 -}
   9.257 -
   9.258 -char *SDL_AudioDriverName(char *namebuf, int maxlen)
   9.259 -{
   9.260 -	if ( current_audio != NULL ) {
   9.261 -		strncpy(namebuf, current_audio->name, maxlen-1);
   9.262 -		namebuf[maxlen-1] = '\0';
   9.263 -		return(namebuf);
   9.264 -	}
   9.265 -	return(NULL);
   9.266 -}
   9.267 -
   9.268 -int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
   9.269 -{
   9.270 -	SDL_AudioDevice *audio;
   9.271 -
   9.272 -	/* Start up the audio driver, if necessary */
   9.273 -	if ( ! current_audio ) {
   9.274 -		if ( (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) ||
   9.275 -		     (current_audio == NULL) ) {
   9.276 -			return(-1);
   9.277 -		}
   9.278 -	}
   9.279 -	audio = current_audio;
   9.280 -
   9.281 -	D(bug("Chiamata SDL_OpenAudio...\n"));
   9.282 -
   9.283 -	/* Verify some parameters */
   9.284 -	if ( desired->callback == NULL ) {
   9.285 -		SDL_SetError("SDL_OpenAudio() passed a NULL callback");
   9.286 -		return(-1);
   9.287 -	}
   9.288 -	switch ( desired->channels ) {
   9.289 -	    case 1:	/* Mono */
   9.290 -	    case 2:	/* Stereo */
   9.291 -		break;
   9.292 -	    default:
   9.293 -		SDL_SetError("1 (mono) and 2 (stereo) channels supported");
   9.294 -		return(-1);
   9.295 -	}
   9.296 -
   9.297 -	/* Create a semaphore for locking the sound buffers */
   9.298 -	InitSemaphore(&audio->mixer_lock);
   9.299 -
   9.300 -	/* Calculate the silence and size of the audio specification */
   9.301 -	SDL_CalculateAudioSpec(desired);
   9.302 -
   9.303 -	/* Open the audio subsystem */
   9.304 -	memcpy(&audio->spec, desired, sizeof(audio->spec));
   9.305 -	audio->convert.needed = 0;
   9.306 -	audio->enabled = 1;
   9.307 -	audio->paused  = 1;
   9.308 -
   9.309 -	ObtainSemaphore(&AudioSem);
   9.310 -
   9.311 -	audio->thread = SDL_CreateThread(RunAudio, audio);
   9.312 -
   9.313 -	if ( audio->thread == NULL ) {
   9.314 -		ReleaseSemaphore(&AudioSem);
   9.315 -		SDL_CloseAudio();
   9.316 -		SDL_SetError("Couldn't create audio thread");
   9.317 -		return(-1);
   9.318 -	}
   9.319 -
   9.320 -	/* If the audio driver changes the buffer size, accept it */
   9.321 -	if ( audio->spec.samples != desired->samples ) {
   9.322 -		desired->samples = audio->spec.samples;
   9.323 -		SDL_CalculateAudioSpec(desired);
   9.324 -	}
   9.325 -
   9.326 -	/* Allocate a fake audio memory buffer */
   9.327 -	audio->fake_stream = SDL_AllocAudioMem(audio->spec.size);
   9.328 -	if ( audio->fake_stream == NULL ) {
   9.329 -		ReleaseSemaphore(&AudioSem);
   9.330 -		SDL_CloseAudio();
   9.331 -		SDL_OutOfMemory();
   9.332 -		return(-1);
   9.333 -	}
   9.334 -
   9.335 -	/* See if we need to do any conversion */
   9.336 -	if ( memcmp(desired, &audio->spec, sizeof(audio->spec)) == 0 ) {
   9.337 -		/* Just copy over the desired audio specification */
   9.338 -		if ( obtained != NULL ) {
   9.339 -			memcpy(obtained, &audio->spec, sizeof(audio->spec));
   9.340 -		}
   9.341 -	} else {
   9.342 -		/* Copy over the audio specification if possible */
   9.343 -		if ( obtained != NULL ) {
   9.344 -			memcpy(obtained, &audio->spec, sizeof(audio->spec));
   9.345 -		} else {
   9.346 -			/* Build an audio conversion block */
   9.347 -			D(bug("Need conversion:\n desired: C:%ld F:%ld T:%lx\navailable: C:%ld F:%ld T:%lx\n",
   9.348 -				desired->channels, desired->freq, desired->format,
   9.349 -				audio->spec.channels,audio->spec.freq,audio->spec.format));
   9.350 -
   9.351 -			Forbid();
   9.352 -
   9.353 -// Magari poi lo sostiutisco con un semaforo.
   9.354 -
   9.355 -			if ( SDL_BuildAudioCVT(&audio->convert,
   9.356 -				desired->format, desired->channels,
   9.357 -						desired->freq,
   9.358 -				audio->spec.format, audio->spec.channels,
   9.359 -						audio->spec.freq) < 0 ) {
   9.360 -				ReleaseSemaphore(&AudioSem);
   9.361 -				SDL_CloseAudio();
   9.362 -				return(-1);
   9.363 -			}
   9.364 -			if ( audio->convert.needed ) {
   9.365 -				audio->convert.len = desired->size;
   9.366 -				audio->convert.buf =(Uint8 *)SDL_AllocAudioMem(
   9.367 -				   audio->convert.len*audio->convert.len_mult);
   9.368 -				if ( audio->convert.buf == NULL ) {
   9.369 -					ReleaseSemaphore(&AudioSem);
   9.370 -					SDL_CloseAudio();
   9.371 -					SDL_OutOfMemory();
   9.372 -					return(-1);
   9.373 -				}
   9.374 -			}
   9.375 -		}
   9.376 -	}
   9.377 -
   9.378 -	ReleaseSemaphore(&AudioSem);
   9.379 -
   9.380 -	D(bug("SDL_OpenAudio USCITA...\n"));
   9.381 -
   9.382 -	return(0);
   9.383 -}
   9.384 -
   9.385 -SDL_audiostatus SDL_GetAudioStatus(void)
   9.386 -{
   9.387 -	SDL_AudioDevice *audio = current_audio;
   9.388 -	SDL_audiostatus status;
   9.389 -
   9.390 -	status = SDL_AUDIO_STOPPED;
   9.391 -	if ( audio && audio->enabled ) {
   9.392 -		if ( audio->paused ) {
   9.393 -			status = SDL_AUDIO_PAUSED;
   9.394 -		} else {
   9.395 -			status = SDL_AUDIO_PLAYING;
   9.396 -		}
   9.397 -	}
   9.398 -	return(status);
   9.399 -}
   9.400 -
   9.401 -void SDL_PauseAudio (int pause_on)
   9.402 -{
   9.403 -	SDL_AudioDevice *audio = current_audio;
   9.404 -
   9.405 -	if ( audio ) {
   9.406 -		audio->paused = pause_on;
   9.407 -	}
   9.408 -}
   9.409 -
   9.410 -void SDL_LockAudio (void)
   9.411 -{
   9.412 -	SDL_AudioDevice *audio = current_audio;
   9.413 -
   9.414 -	/* Obtain a lock on the mixing buffers */
   9.415 -	if ( audio ) {
   9.416 -		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
   9.417 -			return;
   9.418 -		}
   9.419 -		ObtainSemaphore(&audio->mixer_lock);
   9.420 -	}
   9.421 -}
   9.422 -
   9.423 -void SDL_UnlockAudio (void)
   9.424 -{
   9.425 -	SDL_AudioDevice *audio = current_audio;
   9.426 -
   9.427 -	/* Release lock on the mixing buffers */
   9.428 -	if ( audio ) {
   9.429 -		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
   9.430 -			return;
   9.431 -		}
   9.432 -		ReleaseSemaphore(&audio->mixer_lock);
   9.433 -	}
   9.434 -}
   9.435 -
   9.436 -void SDL_CloseAudio (void)
   9.437 -{
   9.438 -	SDL_AudioDevice *audio = current_audio;
   9.439 -
   9.440 -	if ( audio ) {
   9.441 -		if(audio->enabled)
   9.442 -		{
   9.443 -			audio->enabled = 0;
   9.444 -
   9.445 -			if ( audio->thread != NULL ) {
   9.446 -				D(bug("Waiting audio thread...\n"));
   9.447 -				SDL_WaitThread(audio->thread, NULL);
   9.448 -				D(bug("...audio replied\n"));
   9.449 -			}
   9.450 -		}
   9.451 -
   9.452 -		if ( audio->fake_stream != NULL ) {
   9.453 -			SDL_FreeAudioMem(audio->fake_stream);
   9.454 -			audio->fake_stream=NULL;
   9.455 -		}
   9.456 -		if ( audio->convert.needed && current_audio->convert.buf!=NULL) {
   9.457 -			SDL_FreeAudioMem(audio->convert.buf);
   9.458 -			current_audio->convert.buf=NULL;
   9.459 -		}
   9.460 -	}
   9.461 -	SDL_QuitSubSystem(SDL_INIT_AUDIO);
   9.462 -}
   9.463 -
   9.464 -void SDL_AudioQuit(void)
   9.465 -{
   9.466 -	if ( current_audio ) {
   9.467 -		if(current_audio->enabled)
   9.468 -		{
   9.469 -			D(bug("Closing audio in AudioQuit...\n"));
   9.470 -			current_audio->enabled = 0;
   9.471 -
   9.472 -			if ( current_audio->thread != NULL ) {
   9.473 -				D(bug("Waiting audio thread...\n"));
   9.474 -				SDL_WaitThread(current_audio->thread, NULL);
   9.475 -				D(bug("...audio replied\n"));
   9.476 -			}
   9.477 -		}
   9.478 -		if ( current_audio->fake_stream != NULL ) {
   9.479 -			SDL_FreeAudioMem(current_audio->fake_stream);
   9.480 -		}
   9.481 -		if ( current_audio->convert.needed && 
   9.482 -				current_audio->convert.buf) {
   9.483 -			SDL_FreeAudioMem(current_audio->convert.buf);
   9.484 -		}
   9.485 -
   9.486 -		current_audio->free(current_audio);
   9.487 -		current_audio = NULL;
   9.488 -	}
   9.489 -}
   9.490 -
   9.491 -#define NUM_FORMATS	6
   9.492 -static int format_idx;
   9.493 -static int format_idx_sub;
   9.494 -static Uint16 format_list[NUM_FORMATS][NUM_FORMATS] = {
   9.495 - { AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
   9.496 - { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
   9.497 - { AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8 },
   9.498 - { AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8 },
   9.499 - { AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8, AUDIO_S8 },
   9.500 - { AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8, AUDIO_S8 },
   9.501 -};
   9.502 -
   9.503 -Uint16 SDL_FirstAudioFormat(Uint16 format)
   9.504 -{
   9.505 -	for ( format_idx=0; format_idx < NUM_FORMATS; ++format_idx ) {
   9.506 -		if ( format_list[format_idx][0] == format ) {
   9.507 -			break;
   9.508 -		}
   9.509 -	}
   9.510 -	format_idx_sub = 0;
   9.511 -	return(SDL_NextAudioFormat());
   9.512 -}
   9.513 -
   9.514 -Uint16 SDL_NextAudioFormat(void)
   9.515 -{
   9.516 -	if ( (format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS) ) {
   9.517 -		return(0);
   9.518 -	}
   9.519 -	return(format_list[format_idx][format_idx_sub++]);
   9.520 -}
   9.521 -
   9.522 -void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
   9.523 -{
   9.524 -	switch (spec->format) {
   9.525 -		case AUDIO_U8:
   9.526 -			spec->silence = 0x80;
   9.527 -			break;
   9.528 -		default:
   9.529 -			spec->silence = 0x00;
   9.530 -			break;
   9.531 -	}
   9.532 -	spec->size = (spec->format&0xFF)/8;
   9.533 -	spec->size *= spec->channels;
   9.534 -	spec->size *= spec->samples;
   9.535 -}
    10.1 --- a/src/audio/amigaos/SDL_lowaudio.h	Thu May 10 20:10:54 2001 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,58 +0,0 @@
    10.4 -/*
    10.5 -    SDL - Simple DirectMedia Layer
    10.6 -    Copyright (C) 1997, 1998, 1999, 2000, 2001  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 Library General Public
   10.10 -    License as published by the Free Software Foundation; either
   10.11 -    version 2 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 -    Library General Public License for more details.
   10.17 -
   10.18 -    You should have received a copy of the GNU Library General Public
   10.19 -    License along with this library; if not, write to the Free
   10.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   10.21 -
   10.22 -    Sam Lantinga
   10.23 -    slouken@devolution.com
   10.24 -*/
   10.25 -
   10.26 -#ifdef SAVE_RCSID
   10.27 -static char rcsid =
   10.28 - "@(#) $Id$";
   10.29 -#endif
   10.30 -
   10.31 -#ifndef _SDL_lowaudio_h
   10.32 -#define _SDL_lowaudio_h
   10.33 -
   10.34 -// #include <libraries/ahi_sub.h>
   10.35 -
   10.36 -#include "SDL_sysaudio.h"
   10.37 -#include <stdio.h>
   10.38 -#include <stdlib.h>
   10.39 -#include <string.h>
   10.40 -
   10.41 -/* Hidden "this" pointer for the audio functions */
   10.42 -#define _THIS	SDL_AudioDevice *this
   10.43 -
   10.44 -struct SDL_PrivateAudioData {
   10.45 -	/* The handle for the audio device */
   10.46 -	struct AHIRequest *audio_req[2];
   10.47 -	struct MsgPort *audio_port;
   10.48 -	Sint32 freq,type,bytespersample;
   10.49 -	Uint8 *mixbuf[2];           /* The app mixing buffer */
   10.50 -	int current_buffer;
   10.51 -	Uint32 playing;
   10.52 -};
   10.53 -
   10.54 -/* Old variable names */
   10.55 -#define audio_port		(this->hidden->audio_port)
   10.56 -#define audio_req		(this->hidden->audio_req)
   10.57 -#define mixbuf			(this->hidden->mixbuf)
   10.58 -#define current_buffer		(this->hidden->current_buffer)
   10.59 -#define playing			(this->hidden->playing)
   10.60 -
   10.61 -#endif /* _SDL_lowaudio_h */
    11.1 --- a/src/audio/amigaos/SDL_sysaudio.h	Thu May 10 20:10:54 2001 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,142 +0,0 @@
    11.4 -/*
    11.5 -    SDL - Simple DirectMedia Layer
    11.6 -    Copyright (C) 1997, 1998, 1999, 2000, 2001  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 Library General Public
   11.10 -    License as published by the Free Software Foundation; either
   11.11 -    version 2 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 -    Library General Public License for more details.
   11.17 -
   11.18 -    You should have received a copy of the GNU Library General Public
   11.19 -    License along with this library; if not, write to the Free
   11.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   11.21 -
   11.22 -    Sam Lantinga
   11.23 -    slouken@devolution.com
   11.24 -*/
   11.25 -
   11.26 -#ifdef SAVE_RCSID
   11.27 -static char rcsid =
   11.28 - "@(#) $Id$";
   11.29 -#endif
   11.30 -
   11.31 -#ifndef _SDL_sysaudio_h
   11.32 -#define _SDL_sysaudio_h
   11.33 -
   11.34 -#include "SDL_mutex.h"
   11.35 -#include "SDL_thread.h"
   11.36 -
   11.37 -#include <exec/exec.h>
   11.38 -#include <dos/dos.h>
   11.39 -#ifdef __SASC
   11.40 -#include <proto/exec.h>
   11.41 -#else
   11.42 -#include <inline/exec.h>
   11.43 -#endif
   11.44 -
   11.45 -#include <devices/ahi.h>
   11.46 -#include "mydebug.h"
   11.47 -
   11.48 -/* The SDL audio driver */
   11.49 -typedef struct SDL_AudioDevice SDL_AudioDevice;
   11.50 -
   11.51 -/* Define the SDL audio driver structure */
   11.52 -#define _THIS	SDL_AudioDevice *_this
   11.53 -#ifndef _STATUS
   11.54 -#define _STATUS	SDL_status *status
   11.55 -#endif
   11.56 -struct SDL_AudioDevice {
   11.57 -	/* * * */
   11.58 -	/* The name of this audio driver */
   11.59 -	const char *name;
   11.60 -
   11.61 -	/* * * */
   11.62 -	/* Public driver functions */
   11.63 -	int  (*OpenAudio)(_THIS, SDL_AudioSpec *spec);
   11.64 -	void (*ThreadInit)(_THIS);	/* Called by audio thread at start */
   11.65 -	void (*WaitAudio)(_THIS);
   11.66 -	void (*PlayAudio)(_THIS);
   11.67 -	Uint8 *(*GetAudioBuf)(_THIS);
   11.68 -	void (*WaitDone)(_THIS);
   11.69 -	void (*CloseAudio)(_THIS);
   11.70 -
   11.71 -	/* * * */
   11.72 -	/* Data common to all devices */
   11.73 -
   11.74 -	/* The current audio specification (shared with audio thread) */
   11.75 -	SDL_AudioSpec spec;
   11.76 -
   11.77 -	/* An audio conversion block for audio format emulation */
   11.78 -	SDL_AudioCVT convert;
   11.79 -
   11.80 -	/* Current state flags */
   11.81 -	int enabled;
   11.82 -	int paused;
   11.83 -
   11.84 -	/* Fake audio buffer for when the audio hardware is busy */
   11.85 -	Uint8 *fake_stream;
   11.86 -
   11.87 -	/* A semaphore for locking the mixing buffers */
   11.88 -	struct SignalSemaphore mixer_lock;
   11.89 -
   11.90 -	/* A thread to feed the audio device */
   11.91 -	SDL_Thread *thread;
   11.92 -	Uint32 threadid;
   11.93 -
   11.94 -	/* * * */
   11.95 -	/* Data private to this driver */
   11.96 -	struct SDL_PrivateAudioData *hidden;
   11.97 -
   11.98 -	/* * * */
   11.99 -	/* The function used to dispose of this structure */
  11.100 -	void (*free)(_THIS);
  11.101 -};
  11.102 -#undef _THIS
  11.103 -
  11.104 -typedef struct AudioBootStrap {
  11.105 -	const char *name;
  11.106 -	int (*available)(void);
  11.107 -	SDL_AudioDevice *(*create)(int devindex);
  11.108 -} AudioBootStrap;
  11.109 -
  11.110 -#ifdef ESD_SUPPORT
  11.111 -extern AudioBootStrap ESD_bootstrap;
  11.112 -#endif
  11.113 -#ifdef linux
  11.114 -extern AudioBootStrap DMA_bootstrap;
  11.115 -#endif
  11.116 -#ifdef unix
  11.117 -extern AudioBootStrap AUDIO_bootstrap;
  11.118 -#endif
  11.119 -#ifdef ENABLE_WINDIB
  11.120 -extern AudioBootStrap WAVEOUT_bootstrap;
  11.121 -#endif
  11.122 -#ifdef ENABLE_DIRECTX
  11.123 -extern AudioBootStrap DSOUND_bootstrap;
  11.124 -#endif
  11.125 -#ifdef __BEOS__
  11.126 -extern AudioBootStrap BAUDIO_bootstrap;
  11.127 -#endif
  11.128 -#ifdef macintosh
  11.129 -extern AudioBootStrap AUDIO_bootstrap;
  11.130 -#endif
  11.131 -#ifdef _AIX
  11.132 -extern AudioBootStrap Paud_bootstrap;
  11.133 -#endif
  11.134 -#ifdef ENABLE_CYBERGRAPHICS
  11.135 -extern AudioBootStrap AHI_bootstrap;
  11.136 -#endif
  11.137 -
  11.138 -/* This is the current audio device */
  11.139 -extern SDL_AudioDevice *current_audio;
  11.140 -
  11.141 -#ifndef __SASC
  11.142 -extern struct ExecBase *SysBase;
  11.143 -#endif
  11.144 -
  11.145 -#endif /* _SDL_sysaudio_h */
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/joystick/amigaos/Makefile.am	Thu May 10 20:13:29 2001 +0000
    12.3 @@ -0,0 +1,8 @@
    12.4 +
    12.5 +## Makefile.am for the AmigaOS joystick driver for SDL
    12.6 +
    12.7 +noinst_LTLIBRARIES = libjoystick_amiga.la
    12.8 +libjoystick_amiga_la_SOURCES = $(SRCS)
    12.9 +
   12.10 +# The SDL joystick driver sources
   12.11 +SRCS =  SDL_sysjoystick.c
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/joystick/amigaos/SDL_sysjoystick.c	Thu May 10 20:13:29 2001 +0000
    13.3 @@ -0,0 +1,240 @@
    13.4 +/*
    13.5 +    SDL - Simple DirectMedia Layer
    13.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  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 Library General Public
   13.10 +    License as published by the Free Software Foundation; either
   13.11 +    version 2 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 +    Library General Public License for more details.
   13.17 +
   13.18 +    You should have received a copy of the GNU Library General Public
   13.19 +    License along with this library; if not, write to the Free
   13.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   13.21 +
   13.22 +    Sam Lantinga
   13.23 +    slouken@devolution.com
   13.24 +*/
   13.25 +
   13.26 +
   13.27 +#ifdef SAVE_RCSID
   13.28 +static char rcsid =
   13.29 + "@(#) $Id$";
   13.30 +#endif
   13.31 +
   13.32 +/* This is the system specific header for the SDL joystick API */
   13.33 +
   13.34 +#include <stdio.h>		/* For the definition of NULL */
   13.35 +
   13.36 +#include <libraries/lowlevel.h>
   13.37 +#ifdef __SASC
   13.38 +#include <proto/exec.h>
   13.39 +#include <proto/lowlevel.h>
   13.40 +#include <proto/graphics.h>
   13.41 +#else
   13.42 +#include <inline/exec.h>
   13.43 +#include <inline/lowlevel.h>
   13.44 +#include <inline/graphics.h>
   13.45 +#endif
   13.46 +#include "mydebug.h"
   13.47 +
   13.48 +extern struct ExecBase *SysBase;
   13.49 +extern struct GfxBase *GfxBase;
   13.50 +#include <stdlib.h>
   13.51 +
   13.52 +#include "SDL_error.h"
   13.53 +#include "SDL_joystick.h"
   13.54 +#include "SDL_sysjoystick.h"
   13.55 +#include "SDL_joystick_c.h"
   13.56 +
   13.57 +/* Function to scan the system for joysticks.
   13.58 + * This function should set SDL_numjoysticks to the number of available
   13.59 + * joysticks.  Joystick 0 should be the system default joystick.
   13.60 + * It should return 0, or -1 on an unrecoverable fatal error.
   13.61 + */
   13.62 +
   13.63 +
   13.64 +/* Amiga specific datas */
   13.65 +struct Library *LowLevelBase=NULL;
   13.66 +
   13.67 +ULONG joybut[]=
   13.68 +{
   13.69 +	JPF_BUTTON_RED,
   13.70 +	JPF_BUTTON_BLUE,
   13.71 +	JPF_BUTTON_PLAY,
   13.72 +	JPF_BUTTON_YELLOW,
   13.73 +	JPF_BUTTON_GREEN,
   13.74 +	JPF_BUTTON_FORWARD,
   13.75 +	JPF_BUTTON_REVERSE,
   13.76 +};
   13.77 +
   13.78 +struct joystick_hwdata 
   13.79 +{
   13.80 +	ULONG joystate;
   13.81 +};
   13.82 +
   13.83 +int SDL_SYS_JoystickInit(void)
   13.84 +{
   13.85 +	if(!LowLevelBase)
   13.86 +	{
   13.87 +		if(LowLevelBase=OpenLibrary("lowlevel.library",37))
   13.88 +			return 2;
   13.89 +	}
   13.90 +	else
   13.91 +		return 2;
   13.92 +
   13.93 +	D(bug("%ld joysticks available.\n",SDL_numjoysticks));
   13.94 +
   13.95 +	return 0;
   13.96 +}
   13.97 +
   13.98 +/* Function to get the device-dependent name of a joystick */
   13.99 +const char *SDL_SYS_JoystickName(int index)
  13.100 +{
  13.101 +	if(index<2&&LowLevelBase)
  13.102 +	{
  13.103 +		switch(index)
  13.104 +		{
  13.105 +			case 0:
  13.106 +				return "Port 1 Amiga Joystick/Joypad";
  13.107 +			case 1:
  13.108 +				return "Port 2 Amiga Joystick/Joypad";
  13.109 +		}
  13.110 +	}
  13.111 +
  13.112 +	SDL_SetError("No joystick available with that index");
  13.113 +	return(NULL);
  13.114 +}
  13.115 +
  13.116 +/* Function to open a joystick for use.
  13.117 +   The joystick to open is specified by the index field of the joystick.
  13.118 +   This should fill the nbuttons and naxes fields of the joystick structure.
  13.119 +   It returns 0, or -1 if there is an error.
  13.120 + */
  13.121 +
  13.122 +int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
  13.123 +{
  13.124 +	ULONG temp,i;
  13.125 +	D(bug("Opening joystick %ld\n",joystick->index));
  13.126 +
  13.127 +	if(!(joystick->hwdata=malloc(sizeof(struct joystick_hwdata))))
  13.128 +		return -1;
  13.129 +
  13.130 +/* This loop is to check if the controller is a joypad */
  13.131 +
  13.132 +	for(i=0;i<20;i++)
  13.133 +	{
  13.134 +		temp=ReadJoyPort(joystick->index);
  13.135 +		WaitTOF();
  13.136 +	}
  13.137 +
  13.138 +	if((temp&JP_TYPE_MASK)==JP_TYPE_GAMECTLR)
  13.139 +		joystick->nbuttons=7;
  13.140 +	else
  13.141 +		joystick->nbuttons=3;
  13.142 +
  13.143 +	joystick->nhats=0;
  13.144 +	joystick->nballs=0;
  13.145 +	joystick->naxes=2;
  13.146 +	joystick->hwdata->joystate=0L;
  13.147 +
  13.148 +	return 0;
  13.149 +}
  13.150 +
  13.151 +/* Function to update the state of a joystick - called as a device poll.
  13.152 + * This function shouldn't update the joystick structure directly,
  13.153 + * but instead should call SDL_PrivateJoystick*() to deliver events
  13.154 + * and update joystick device state.
  13.155 + */
  13.156 +void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
  13.157 +{
  13.158 +	ULONG data;	
  13.159 +	int i;
  13.160 +
  13.161 +	if(joystick->index<2)
  13.162 +	{
  13.163 +		data=ReadJoyPort(joystick->index);
  13.164 +
  13.165 +		if(data&JP_DIRECTION_MASK)
  13.166 +		{
  13.167 +			if(data&JPF_JOY_DOWN)
  13.168 +			{
  13.169 +				if(!(joystick->hwdata->joystate&JPF_JOY_DOWN))
  13.170 +					SDL_PrivateJoystickAxis(joystick,0,127);
  13.171 +			}
  13.172 +			else if(data&JPF_JOY_UP)
  13.173 +			{
  13.174 +				if(!(joystick->hwdata->joystate&JPF_JOY_UP))
  13.175 +					SDL_PrivateJoystickAxis(joystick,0,-127);
  13.176 +			}
  13.177 +			else if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN))
  13.178 +				SDL_PrivateJoystickAxis(joystick,0,0);
  13.179 +
  13.180 +			if(data&JPF_JOY_LEFT)
  13.181 +			{
  13.182 +				if(!(joystick->hwdata->joystate&JPF_JOY_LEFT))
  13.183 +					SDL_PrivateJoystickAxis(joystick,1,-127);
  13.184 +			}
  13.185 +			else if(data&JPF_JOY_RIGHT)
  13.186 +			{
  13.187 +				if(!(joystick->hwdata->joystate&JPF_JOY_RIGHT))
  13.188 +					SDL_PrivateJoystickAxis(joystick,1,127);
  13.189 +			}
  13.190 +			else if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT))
  13.191 +				SDL_PrivateJoystickAxis(joystick,1,0);
  13.192 +		}
  13.193 +		else if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT))
  13.194 +		{
  13.195 +				SDL_PrivateJoystickAxis(joystick,1,0);
  13.196 +		}
  13.197 +		else if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN))
  13.198 +		{
  13.199 +				SDL_PrivateJoystickAxis(joystick,0,0);
  13.200 +		}
  13.201 +
  13.202 +		for(i=0;i<joystick->nbuttons;i++)
  13.203 +		{
  13.204 +			if( (data&joybut[i]) )
  13.205 +			{
  13.206 +				if(i==1)
  13.207 +					data&=(~(joybut[2]));
  13.208 +
  13.209 +				if(!(joystick->hwdata->joystate&joybut[i]))
  13.210 +					SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED);
  13.211 +			}
  13.212 +			else if(joystick->hwdata->joystate&joybut[i])
  13.213 +				SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED);
  13.214 +		}
  13.215 +
  13.216 +		joystick->hwdata->joystate=data;
  13.217 +	}
  13.218 +
  13.219 +	return;
  13.220 +}
  13.221 +
  13.222 +/* Function to close a joystick after use */
  13.223 +void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
  13.224 +{
  13.225 +	if(joystick->hwdata)
  13.226 +		free(joystick->hwdata);
  13.227 +	return;
  13.228 +}
  13.229 +
  13.230 +/* Function to perform any system-specific joystick related cleanup */
  13.231 +
  13.232 +void SDL_SYS_JoystickQuit(void)
  13.233 +{
  13.234 +	if(LowLevelBase)
  13.235 +	{
  13.236 +		CloseLibrary(LowLevelBase);
  13.237 +		LowLevelBase=NULL;
  13.238 +		SDL_numjoysticks=0;
  13.239 +	}
  13.240 +
  13.241 +	return;
  13.242 +}
  13.243 +
    14.1 --- a/src/thread/amigaos/SDL_syssem.c	Thu May 10 20:10:54 2001 +0000
    14.2 +++ b/src/thread/amigaos/SDL_syssem.c	Thu May 10 20:13:29 2001 +0000
    14.3 @@ -25,7 +25,7 @@
    14.4   "@(#) $Id$";
    14.5  #endif
    14.6  
    14.7 -/* An native implementation of semaphores on AmigaOS */
    14.8 +/* An implementation of semaphores using mutexes and condition variables */
    14.9  
   14.10  #include "SDL_error.h"
   14.11  #include "SDL_thread.h"
   14.12 @@ -35,9 +35,13 @@
   14.13  struct SDL_semaphore
   14.14  {
   14.15  	struct SignalSemaphore Sem;
   14.16 +	Uint32 count;
   14.17 +	Uint32 waiters_count;
   14.18 +	SDL_mutex *count_lock;
   14.19 +	SDL_cond *count_nonzero;
   14.20  };
   14.21  
   14.22 -#undef D(x)
   14.23 +#undef D
   14.24  
   14.25  #define D(x)
   14.26  
   14.27 @@ -46,20 +50,18 @@
   14.28  	SDL_sem *sem;
   14.29  
   14.30  	sem = (SDL_sem *)malloc(sizeof(*sem));
   14.31 +
   14.32  	if ( ! sem ) {
   14.33  		SDL_OutOfMemory();
   14.34  		return(0);
   14.35  	}
   14.36 -	memset(sem, 0, sizeof(*sem));
   14.37  
   14.38  	D(bug("Creating semaphore %lx...\n",sem));
   14.39  
   14.40 +	memset(sem,0,sizeof(*sem));
   14.41 +
   14.42  	InitSemaphore(&sem->Sem);
   14.43 -#if 1 // Allow multiple obtainings of the semaphore
   14.44 -        while ( initial_value-- ) {
   14.45 -		ReleaseSemaphore(&sem->Sem);
   14.46 -	}
   14.47 -#endif
   14.48 +	
   14.49  	return(sem);
   14.50  }
   14.51  
   14.52 @@ -75,8 +77,6 @@
   14.53  
   14.54  int SDL_SemTryWait(SDL_sem *sem)
   14.55  {
   14.56 -	int retval;
   14.57 -
   14.58  	if ( ! sem ) {
   14.59  		SDL_SetError("Passed a NULL semaphore");
   14.60  		return -1;
   14.61 @@ -84,17 +84,17 @@
   14.62  
   14.63  	D(bug("TryWait semaphore...%lx\n",sem));
   14.64  
   14.65 -	retval = SDL_MUTEX_TIMEDOUT;
   14.66 -	if ( AttemptSemaphore(&sem->Sem) ) {
   14.67 -		retval = 0;
   14.68 -	}
   14.69 -	return retval;
   14.70 +	ObtainSemaphore(&sem->Sem);
   14.71 +//	ReleaseSemaphore(&sem->Sem);
   14.72 +
   14.73 +	return 1;
   14.74  }
   14.75  
   14.76  int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
   14.77  {
   14.78  	int retval;
   14.79  
   14.80 +
   14.81  	if ( ! sem ) {
   14.82  		SDL_SetError("Passed a NULL semaphore");
   14.83  		return -1;
   14.84 @@ -102,16 +102,22 @@
   14.85  
   14.86  	D(bug("WaitTimeout (%ld) semaphore...%lx\n",timeout,sem));
   14.87  
   14.88 -#if 1 // We need to keep trying the semaphore until the timeout expires
   14.89 -	retval = SDL_MUTEX_TIMEDOUT;
   14.90 -	then = SDL_GetTicks();
   14.91 -	do {
   14.92 -		if ( AttemptSemaphore(&sem->Sem) ) {
   14.93 -			retval = 0;
   14.94 -		}
   14.95 -		now = SDL_GetTicks();
   14.96 -	} while ( (retval == SDL_MUTEX_TIMEDOUT) && ((now-then) < timeout) );
   14.97 -#else
   14.98 +	/* A timeout of 0 is an easy case */
   14.99 +	if ( timeout == 0 ) {
  14.100 +		return SDL_SemTryWait(sem);
  14.101 +	}
  14.102 +/*
  14.103 +	SDL_LockMutex(sem->count_lock);
  14.104 +	++sem->waiters_count;
  14.105 +	retval = 0;
  14.106 +	while ( (sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT) ) {
  14.107 +		retval = SDL_CondWaitTimeout(sem->count_nonzero,
  14.108 +		                             sem->count_lock, timeout);
  14.109 +	}
  14.110 +	--sem->waiters_count;
  14.111 +	--sem->count;
  14.112 +	SDL_UnlockMutex(sem->count_lock);
  14.113 +*/
  14.114  	if(!(retval=AttemptSemaphore(&sem->Sem)))
  14.115  	{
  14.116  		SDL_Delay(timeout);
  14.117 @@ -123,22 +129,15 @@
  14.118  //		ReleaseSemaphore(&sem->Sem);
  14.119  		retval=1;
  14.120  	}
  14.121 -#endif
  14.122 +
  14.123  	return retval;
  14.124  }
  14.125  
  14.126  int SDL_SemWait(SDL_sem *sem)
  14.127  {
  14.128 -	if ( ! sem ) {
  14.129 -		SDL_SetError("Passed a NULL semaphore");
  14.130 -		return -1;
  14.131 -	}
  14.132 -#if 1 // This should be an infinite wait - FIXME, what is the return value?
  14.133  	ObtainSemaphore(&sem->Sem);
  14.134 -        return 0;
  14.135 -#else
  14.136 -	return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
  14.137 -#endif
  14.138 +	return 0;
  14.139 +//	return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
  14.140  }
  14.141  
  14.142  Uint32 SDL_SemValue(SDL_sem *sem)
  14.143 @@ -148,6 +147,7 @@
  14.144  	value = 0;
  14.145  	if ( sem ) {
  14.146  		value = sem->Sem.ss_NestCount;
  14.147 +//		SDL_UnlockMutex(sem->count_lock);
  14.148  	}
  14.149  	return value;
  14.150  }
  14.151 @@ -161,6 +161,14 @@
  14.152  	D(bug("SemPost semaphore...%lx\n",sem));
  14.153  
  14.154  	ReleaseSemaphore(&sem->Sem);
  14.155 +#if 0
  14.156 +	SDL_LockMutex(sem->count_lock);
  14.157 +	if ( sem->waiters_count > 0 ) {
  14.158 +		SDL_CondSignal(sem->count_nonzero);
  14.159 +	}
  14.160 +	++sem->count;
  14.161 +	SDL_UnlockMutex(sem->count_lock);
  14.162 +#endif
  14.163  	return 0;
  14.164  }
  14.165  
    15.1 --- a/src/thread/amigaos/SDL_systhread.c	Thu May 10 20:10:54 2001 +0000
    15.2 +++ b/src/thread/amigaos/SDL_systhread.c	Thu May 10 20:13:29 2001 +0000
    15.3 @@ -25,7 +25,7 @@
    15.4   "@(#) $Id$";
    15.5  #endif
    15.6  
    15.7 -/* AmigaOS thread management routines for SDL */
    15.8 +/* BeOS thread management routines for SDL */
    15.9  
   15.10  #include "SDL_error.h"
   15.11  #include "SDL_mutex.h"
   15.12 @@ -40,6 +40,8 @@
   15.13  	struct Task *wait;
   15.14  } thread_args;
   15.15  
   15.16 +#ifndef MORPHOS
   15.17 +
   15.18  #if defined(__SASC) && !defined(__PPC__) 
   15.19  __saveds __asm Uint32 RunThread(register __a0 char *args )
   15.20  #elif defined(__PPC__)
   15.21 @@ -60,6 +62,34 @@
   15.22  	return(0);
   15.23  }
   15.24  
   15.25 +#else
   15.26 +
   15.27 +#include <emul/emulinterface.h>
   15.28 +
   15.29 +Uint32 RunTheThread(void)
   15.30 +{
   15.31 +	thread_args *data=(thread_args *)atol(REG_A0);
   15.32 +	struct Task *Father;
   15.33 +
   15.34 +	D(bug("Received data: %lx\n",data));
   15.35 +	Father=data->wait;
   15.36 +
   15.37 +	SDL_RunThread(data);
   15.38 +
   15.39 +	Signal(Father,SIGBREAKF_CTRL_F);
   15.40 +	return(0);
   15.41 +}
   15.42 +
   15.43 +struct EmulLibEntry RunThread=
   15.44 +{
   15.45 +	TRAP_LIB,
   15.46 +	0,
   15.47 +	RunTheThread
   15.48 +};
   15.49 +
   15.50 +#endif
   15.51 +
   15.52 +
   15.53  int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
   15.54  {
   15.55  	/* Create the thread and go! */
   15.56 @@ -98,6 +128,7 @@
   15.57  
   15.58  void SDL_SYS_WaitThread(SDL_Thread *thread)
   15.59  {
   15.60 +	SetSignal(0L,SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C);
   15.61  	Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C);
   15.62  }
   15.63  
    16.1 --- a/src/thread/amigaos/SDL_thread.c	Thu May 10 20:10:54 2001 +0000
    16.2 +++ b/src/thread/amigaos/SDL_thread.c	Thu May 10 20:13:29 2001 +0000
    16.3 @@ -265,6 +265,18 @@
    16.4  	}
    16.5  }
    16.6  
    16.7 +Uint32 SDL_GetThreadID(SDL_Thread *thread)
    16.8 +{
    16.9 +	Uint32 id;
   16.10 +
   16.11 +	if ( thread ) {
   16.12 +		id = thread->threadid;
   16.13 +	} else {
   16.14 +		id = SDL_ThreadID();
   16.15 +	}
   16.16 +	return(id);
   16.17 +}
   16.18 +
   16.19  void SDL_KillThread(SDL_Thread *thread)
   16.20  {
   16.21  	if ( thread ) {
    17.1 --- a/src/timer/amigaos/SDL_systimer.c	Thu May 10 20:10:54 2001 +0000
    17.2 +++ b/src/timer/amigaos/SDL_systimer.c	Thu May 10 20:13:29 2001 +0000
    17.3 @@ -26,98 +26,221 @@
    17.4  #endif
    17.5  
    17.6  #include <stdio.h>
    17.7 -#include <sys/time.h>
    17.8 +#include <time.h>
    17.9  #include <signal.h>
   17.10  #include <unistd.h>
   17.11  #include <string.h>
   17.12  #include <errno.h>
   17.13 +#include <exec/types.h>
   17.14 +#ifdef __SASC
   17.15 +#include <proto/dos.h>
   17.16 +#include <clib/graphics_protos.h>
   17.17 +#include <pragmas/graphics.h>
   17.18 +#include <clib/exec_protos.h>
   17.19 +#include <pragmas/exec.h>
   17.20 +#else
   17.21 +#include <inline/dos.h>
   17.22 +#include <inline/exec.h>
   17.23 +#include <inline/graphics.h>
   17.24 +#endif
   17.25 +#include "mydebug.h"
   17.26 +
   17.27 +extern struct DosLibrary *DOSBase;
   17.28 +extern struct ExecBase *SysBase;
   17.29 +static struct GfxBase *GfxBase;
   17.30  
   17.31  #include "SDL_error.h"
   17.32  #include "SDL_timer.h"
   17.33  #include "SDL_timer_c.h"
   17.34  
   17.35 +#if defined(DISABLE_THREADS) || defined(FORK_HACK)
   17.36 +#define USE_ITIMER
   17.37 +#endif
   17.38 +
   17.39  /* The first ticks value of the application */
   17.40 -static struct timeval start;
   17.41 +
   17.42 +#ifndef __PPC__
   17.43 +static clock_t start;
   17.44  
   17.45  void SDL_StartTicks(void)
   17.46  {
   17.47  	/* Set first ticks value */
   17.48 -	gettimeofday(&start, NULL);
   17.49 +	start=clock();
   17.50  }
   17.51  
   17.52  Uint32 SDL_GetTicks (void)
   17.53  {
   17.54 -	struct timeval now;
   17.55 -	Uint32 ticks;
   17.56 +	clock_t ticks;
   17.57  
   17.58 -	gettimeofday(&now, NULL);
   17.59 -	ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
   17.60 +	ticks=clock()-start;
   17.61 +
   17.62 +#ifdef __SASC
   17.63 +// CLOCKS_PER_SEC == 1000 !
   17.64 +
   17.65  	return(ticks);
   17.66 +#else
   17.67 +// CLOCKS_PER_SEC != 1000 !
   17.68 +
   17.69 +	return ticks*(1000/CLOCKS_PER_SEC);
   17.70 +#endif
   17.71  }
   17.72  
   17.73  void SDL_Delay (Uint32 ms)
   17.74  {
   17.75 -	int was_error;
   17.76 -#ifndef linux	/* Non-Linux implementations need to calculate time left */
   17.77 -	Uint32 then, now, elapsed;
   17.78 +// Do a busy wait if time is less than 50ms
   17.79 +
   17.80 +	if(ms<50)
   17.81 +	{
   17.82 +		clock_t to_wait=clock();
   17.83 +
   17.84 +#ifndef __SASC
   17.85 +		ms*=(CLOCKS_PER_SEC/1000);
   17.86  #endif
   17.87 -	struct timeval tv;
   17.88 +		to_wait+=ms;
   17.89  
   17.90 -	/* Set the timeout interval - Linux only needs to do this once */
   17.91 -#ifdef linux
   17.92 -	tv.tv_sec = ms/1000;
   17.93 -	tv.tv_usec = (ms%1000)*1000;
   17.94 +		while(clock()<to_wait);
   17.95 +	}
   17.96 +	else
   17.97 +	{
   17.98 +		Delay(ms/20);
   17.99 +	}
  17.100 +}
  17.101 +
  17.102  #else
  17.103 -	then = SDL_GetTicks();
  17.104 +
  17.105 +ULONG MY_CLOCKS_PER_SEC;
  17.106 +
  17.107 +void PPC_TimerInit(void);
  17.108 +APTR MyTimer;
  17.109 +
  17.110 +ULONG start[2];
  17.111 +
  17.112 +void SDL_StartTicks(void)
  17.113 +{
  17.114 +	/* Set first ticks value */
  17.115 +	if(!MyTimer)
  17.116 +		PPC_TimerInit();
  17.117 +	
  17.118 +	PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,start);
  17.119 +	start[1]>>=10;
  17.120 +	start[1]|=((result[0]&0x3ff)<<22);
  17.121 +	start[0]>>=10;
  17.122 +}
  17.123 +
  17.124 +Uint32 SDL_GetTicks (void)
  17.125 +{
  17.126 +	ULONG result[2];
  17.127 +	PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result);
  17.128 +
  17.129 +//	PPCAsr64p(result,10);
  17.130 +// Non va, la emulo:
  17.131 +	
  17.132 +	result[1]>>=10;
  17.133 +	result[1]|=((result[0]&0x3ff)<<22);
  17.134 +
  17.135 +// Non mi interessa piu' result[0]
  17.136 +
  17.137 +	return result[1]*1000/MY_CLOCKS_PER_SEC;
  17.138 +}
  17.139 +
  17.140 +void SDL_Delay (Uint32 ms)
  17.141 +{
  17.142 +// Do a busy wait if time is less than 50ms
  17.143 +
  17.144 +	if(ms<50)
  17.145 +	{
  17.146 +		ULONG to_wait[2],actual[2];
  17.147 +		PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result);
  17.148 +		actual[1]=0;
  17.149 +		to_wait[1]+=ms*1000/MY_CLOCKS_PER_SEC;
  17.150 +
  17.151 +		while(actual[1]<to_wait[1])
  17.152 +		{
  17.153 +			PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,actual);
  17.154 +		}
  17.155 +	}
  17.156 +	else
  17.157 +	{
  17.158 +		Delay(ms/50);
  17.159 +	}
  17.160 +}
  17.161 +
  17.162 +void PPC_TimerInit(void)
  17.163 +{
  17.164 +	struct TagItem tags[]=
  17.165 +		{
  17.166 +			PPCTIMERTAG_CPU,TRUE,
  17.167 +			TAG_DONE,0
  17.168 +		};
  17.169 +
  17.170 +
  17.171 +	if(MyTimer=PPCCreateTimerObject(tags))
  17.172 +	{
  17.173 +		ULONG result[2];
  17.174 +
  17.175 +		PPCGetTimerObject(MyTimer,PPCTIMERTAG_TICKSPERSEC,result);
  17.176 +		D(bug("Timer inizializzato, TPS: %lu - %lu\n",result[0],result[1]));
  17.177 +//		PPCAsr64p(result,10);
  17.178 +		result[1]>>=10;
  17.179 +		result[1]|=((result[0]&0x3ff)<<22);
  17.180 +		result[0]>>=10;
  17.181 +
  17.182 +		D(bug("Shiftato TPS: %lu - %lu\n",result[0],result[1]));
  17.183 +		MY_CLOCKS_PER_SEC=result[1];
  17.184 +
  17.185 +		PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result);
  17.186 +
  17.187 +		D(bug("Current ticks: %lu - %lu\n",result[0],result[1]));
  17.188 +		result[1]>>=10;
  17.189 +		result[1]|=((result[0]&0x3ff)<<22);
  17.190 +		result[0]>>=10;
  17.191 +//		PPCAsr64p(result,10);
  17.192 +		D(bug("Shiftato: %lu - %lu\n",result[0],result[1]));
  17.193 +	}
  17.194 +	else
  17.195 +	{
  17.196 +		D(bug("Errore nell'inizializzazione del timer!\n"));
  17.197 +	}	
  17.198 +}
  17.199 +
  17.200  #endif
  17.201 -	do {
  17.202 -		errno = 0;
  17.203 -#ifndef linux
  17.204 -		/* Calculate the time interval left (in case of interrupt) */
  17.205 -		now = SDL_GetTicks();
  17.206 -		elapsed = (now-then);
  17.207 -		then = now;
  17.208 -		if ( elapsed >= ms ) {
  17.209 -			break;
  17.210 -		}
  17.211 -		ms -= elapsed;
  17.212 -		tv.tv_sec = ms/1000;
  17.213 -		tv.tv_usec = (ms%1000)*1000;
  17.214 -#endif
  17.215 -		was_error = select(0, NULL, NULL, NULL, &tv);
  17.216 -	} while ( was_error && (errno == EINTR) );
  17.217 -}
  17.218  
  17.219  #include "SDL_thread.h"
  17.220  
  17.221  /* Data to handle a single periodic alarm */
  17.222  static int timer_alive = 0;
  17.223 -static SDL_Thread *timer = NULL;
  17.224 +static SDL_Thread *timer_thread = NULL;
  17.225  
  17.226  static int RunTimer(void *unused)
  17.227  {
  17.228 +	D(bug("SYSTimer: Entering RunTimer loop..."));
  17.229 +
  17.230 +	if(GfxBase==NULL)
  17.231 +		GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",37);
  17.232 +
  17.233  	while ( timer_alive ) {
  17.234  		if ( SDL_timer_running ) {
  17.235  			SDL_ThreadedTimerCheck();
  17.236  		}
  17.237 -		SDL_Delay(1);
  17.238 +		if(GfxBase)
  17.239 +			WaitTOF();  // Check the timer every fifth of seconds. Was SDL_Delay(1)->BusyWait!
  17.240 +		else
  17.241 +			Delay(1);
  17.242  	}
  17.243 +	D(bug("SYSTimer: EXITING RunTimer loop..."));
  17.244  	return(0);
  17.245  }
  17.246  
  17.247  /* This is only called if the event thread is not running */
  17.248  int SDL_SYS_TimerInit(void)
  17.249  {
  17.250 -#ifdef NO_AMIGADEBUG
  17.251 -	fprintf(stderr,"Creo il thread per il timer (NOITMER)...\n");
  17.252 -#endif
  17.253 +	D(bug("Creo il thread per il timer (NOITMER)...\n"));
  17.254 +
  17.255  	timer_alive = 1;
  17.256 -	timer = SDL_CreateThread(RunTimer, NULL);
  17.257 -	if ( timer == NULL )
  17.258 +	timer_thread = SDL_CreateThread(RunTimer, NULL);
  17.259 +	if ( timer_thread == NULL )
  17.260  	{
  17.261 -#ifdef NO_AMIGADEBUG
  17.262 -		fprintf(stderr,"Creazione del thread fallita...\n");
  17.263 -#endif
  17.264 +		D(bug("Creazione del thread fallita...\n"));
  17.265  
  17.266  		return(-1);
  17.267  	}
  17.268 @@ -127,15 +250,15 @@
  17.269  void SDL_SYS_TimerQuit(void)
  17.270  {
  17.271  	timer_alive = 0;
  17.272 -	if ( timer ) {
  17.273 -		SDL_WaitThread(timer, NULL);
  17.274 -		timer = NULL;
  17.275 +	if ( timer_thread ) {
  17.276 +		SDL_WaitThread(timer_thread, NULL);
  17.277 +		timer_thread = NULL;
  17.278  	}
  17.279  }
  17.280  
  17.281  int SDL_SYS_StartTimer(void)
  17.282  {
  17.283 -	SDL_SetError("Internal logic error: Linux uses threaded timer");
  17.284 +	SDL_SetError("Internal logic error: AmigaOS uses threaded timer");
  17.285  	return(-1);
  17.286  }
  17.287  
    18.1 --- a/src/video/cybergfx/SDL_amigaevents.c	Thu May 10 20:10:54 2001 +0000
    18.2 +++ b/src/video/cybergfx/SDL_amigaevents.c	Thu May 10 20:13:29 2001 +0000
    18.3 @@ -255,8 +255,8 @@
    18.4  
    18.5  	    /* Have we been resized? */
    18.6  	    case IDCMP_NEWSIZE: 
    18.7 -			SDL_PrivateResize(SDL_Window->Width,
    18.8 -		                  SDL_Window->Height);
    18.9 +			SDL_PrivateResize(SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight,
   18.10 +		                  SDL_Window->Height-SDL_Window->BorderTop-SDL_Window->BorderBottom);
   18.11  			break;
   18.12  
   18.13  	    /* Have we been requested to quit? */
    19.1 --- a/src/video/cybergfx/SDL_cgxaccel.c	Thu May 10 20:10:54 2001 +0000
    19.2 +++ b/src/video/cybergfx/SDL_cgxaccel.c	Thu May 10 20:13:29 2001 +0000
    19.3 @@ -214,6 +214,8 @@
    19.4  	}
    19.5  	else if(dst->hwdata)
    19.6  		BBB(src->hwdata->bmap,srcrect->x,srcrect->y,dst->hwdata->bmap,dstrect->x,dstrect->y,srcrect->w,srcrect->h,0xc0,0xff,NULL);
    19.7 +
    19.8 +	return 0;
    19.9  }
   19.10  
   19.11  int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color)
   19.12 @@ -234,4 +236,5 @@
   19.13  
   19.14  		FillPixelArray(&temprp,dstrect->x,dstrect->y,dstrect->w,dstrect->h,color);
   19.15  	}
   19.16 +	return 0;
   19.17  }
    20.1 --- a/src/video/cybergfx/SDL_cgximage.c	Thu May 10 20:10:54 2001 +0000
    20.2 +++ b/src/video/cybergfx/SDL_cgximage.c	Thu May 10 20:13:29 2001 +0000
    20.3 @@ -57,6 +57,7 @@
    20.4  {
    20.5  	if(screen->flags&SDL_HWSURFACE)
    20.6  	{
    20.7 +		Uint32 pitch;
    20.8  		SDL_Ximage=NULL;
    20.9  
   20.10  		if(!screen->hwdata)
   20.11 @@ -66,14 +67,30 @@
   20.12  				return -1;
   20.13  			}
   20.14  			D(bug("Creating system accel struct\n"));
   20.15 -			screen->hwdata->lock=0;
   20.16 -			screen->hwdata->bmap=SDL_RastPort->BitMap;
   20.17 -			screen->hwdata->videodata=this;
   20.18  		}
   20.19 +		screen->hwdata->lock=0;
   20.20 +		screen->hwdata->bmap=SDL_RastPort->BitMap;
   20.21 +		screen->hwdata->videodata=this;
   20.22 +
   20.23 +		if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap,
   20.24 +				LBMI_BASEADDRESS,(ULONG)&screen->pixels,
   20.25 +				LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE)))
   20.26 +		{
   20.27 +			free(screen->hwdata);
   20.28 +			screen->hwdata=NULL;
   20.29 +			return -1;
   20.30 +		}
   20.31 +		else
   20.32 +		{
   20.33 +			UnLockBitMap(screen->hwdata->lock);
   20.34 +			screen->hwdata->lock=NULL;
   20.35 +		}
   20.36 +
   20.37 +		screen->pitch=pitch;
   20.38  
   20.39  		this->UpdateRects = CGX_FakeUpdate;
   20.40  
   20.41 -		D(bug("Accel video image configured.\n"));
   20.42 +		D(bug("Accel video image configured (%lx, pitch %ld).\n",screen->pixels,screen->pitch));
   20.43  		return 0;
   20.44  	}
   20.45  
   20.46 @@ -83,6 +100,18 @@
   20.47  		SDL_OutOfMemory();
   20.48  		return(-1);
   20.49  	}
   20.50 +
   20.51 +/*
   20.52 +	{
   20.53 + 	        int bpp = screen->format->BytesPerPixel;
   20.54 +			SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
   20.55 +					  this->hidden->depth, ZPixmap, 0,
   20.56 +					  (char *)screen->pixels, 
   20.57 +					  screen->w, screen->h,
   20.58 +					  (bpp == 3) ? 32 : bpp * 8,
   20.59 +					  0);
   20.60 +	}
   20.61 +*/
   20.62  	SDL_Ximage=screen->pixels;
   20.63  
   20.64  	if ( SDL_Ximage == NULL ) {
   20.65 @@ -106,16 +135,35 @@
   20.66  	}
   20.67  }
   20.68  
   20.69 +/* This is a hack to see whether this system has more than 1 CPU */
   20.70 +static int num_CPU(void)
   20.71 +{
   20.72 +	return 1;
   20.73 +}
   20.74 +
   20.75  int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
   20.76  {
   20.77  	int retval;
   20.78  
   20.79 +	D(bug("Chiamata ResizeImage!\n"));
   20.80 +
   20.81  	CGX_DestroyImage(this, screen);
   20.82  
   20.83 -	if ( flags & SDL_OPENGL ) {  /* No image when using GL */
   20.84 +    if ( flags & SDL_OPENGL ) {  /* No image when using GL */
   20.85          	retval = 0;
   20.86 -	} else {
   20.87 +    } else {
   20.88  		retval = CGX_SetupImage(this, screen);
   20.89 +		/* We support asynchronous blitting on the display */
   20.90 +		if ( flags & SDL_ASYNCBLIT ) {
   20.91 +			/* This is actually slower on single-CPU systems,
   20.92 +			   probably because of CPU contention between the
   20.93 +			   X server and the application.
   20.94 +			   Note: Is this still true with XFree86 4.0?
   20.95 +			*/
   20.96 +			if ( num_CPU() > 1 ) {
   20.97 +				screen->flags |= SDL_ASYNCBLIT;
   20.98 +			}
   20.99 +		}
  20.100  	}
  20.101  	return(retval);
  20.102  }
  20.103 @@ -135,11 +183,11 @@
  20.104  	{
  20.105  		if(!(surface->hwdata=malloc(sizeof(struct private_hwdata))))
  20.106  			return -1;
  20.107 -		
  20.108 -		surface->hwdata->lock=NULL;
  20.109 -		surface->hwdata->videodata=this;
  20.110  	}
  20.111  
  20.112 +	surface->hwdata->lock=NULL;
  20.113 +	surface->hwdata->videodata=this;
  20.114 +
  20.115  	if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap))
  20.116  	{
  20.117  		surface->flags|=SDL_HWSURFACE;
  20.118 @@ -205,7 +253,7 @@
  20.119  	{
  20.120  		UnLockBitMap(surface->hwdata->lock);
  20.121  		surface->hwdata->lock=NULL;
  20.122 -		surface->pixels=NULL;
  20.123 +//		surface->pixels=NULL;
  20.124  	}
  20.125  }
  20.126  
    21.1 --- a/src/video/cybergfx/SDL_cgxmodes.c	Thu May 10 20:10:54 2001 +0000
    21.2 +++ b/src/video/cybergfx/SDL_cgxmodes.c	Thu May 10 20:13:29 2001 +0000
    21.3 @@ -76,6 +76,13 @@
    21.4      *h = SDL_Display->Height;
    21.5  }
    21.6  
    21.7 +static void move_cursor_to(_THIS, int x, int y)
    21.8 +{
    21.9 +/*    XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); */
   21.10 +
   21.11 +/* DA FARE! */
   21.12 +}
   21.13 +
   21.14  static void add_visual(_THIS, int depth, int class)
   21.15  {
   21.16  	Uint32 tID;
    22.1 --- a/src/video/cybergfx/SDL_cgxmodes_c.h	Thu May 10 20:10:54 2001 +0000
    22.2 +++ b/src/video/cybergfx/SDL_cgxmodes_c.h	Thu May 10 20:13:29 2001 +0000
    22.3 @@ -40,5 +40,10 @@
    22.4  extern SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
    22.5  extern void CGX_FreeVideoModes(_THIS);
    22.6  extern int CGX_ResizeFullScreen(_THIS);
    22.7 +/*
    22.8 +extern void CGX_WaitMapped(_THIS, Window win);
    22.9 +extern void CGX_WaitUnmapped(_THIS, Window win);
   22.10 +extern void CGX_QueueEnterFullScreen(_THIS);
   22.11 +*/
   22.12  extern int CGX_EnterFullScreen(_THIS);
   22.13  extern int CGX_LeaveFullScreen(_THIS);
    23.1 --- a/src/video/cybergfx/SDL_cgxvideo.c	Thu May 10 20:10:54 2001 +0000
    23.2 +++ b/src/video/cybergfx/SDL_cgxvideo.c	Thu May 10 20:13:29 2001 +0000
    23.3 @@ -64,8 +64,7 @@
    23.4  static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
    23.5  static int CGX_ToggleFullScreen(_THIS, int on);
    23.6  static void CGX_UpdateMouse(_THIS);
    23.7 -static int CGX_SetColors(_THIS, int firstcolor, int ncolors,
    23.8 -			 SDL_Color *colors);
    23.9 +static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
   23.10  static void CGX_VideoQuit(_THIS);
   23.11  
   23.12  /* CGX driver bootstrap functions */
   23.13 @@ -110,6 +109,7 @@
   23.14  			this->hidden->dbuffer=0;
   23.15  		}
   23.16  		CloseScreen(GFX_Display);
   23.17 +		currently_fullscreen=0;
   23.18  	}
   23.19  	else
   23.20  		UnlockPubScreen(NULL,GFX_Display);
   23.21 @@ -173,6 +173,9 @@
   23.22  	device->SetVideoMode = CGX_SetVideoMode;
   23.23  	device->ToggleFullScreen = CGX_ToggleFullScreen;
   23.24  	device->UpdateMouse = CGX_UpdateMouse;
   23.25 +#ifdef XFREE86_XV
   23.26 +	device->CreateYUVOverlay = X11_CreateYUVOverlay;
   23.27 +#endif
   23.28  	device->SetColors = CGX_SetColors;
   23.29  	device->UpdateRects = NULL;
   23.30  	device->VideoQuit = CGX_VideoQuit;
   23.31 @@ -192,8 +195,8 @@
   23.32  	device->GL_MakeCurrent = X11_GL_MakeCurrent;
   23.33  	device->GL_SwapBuffers = X11_GL_SwapBuffers;
   23.34  #endif
   23.35 +	device->SetIcon = CGX_SetIcon;
   23.36  	device->SetCaption = CGX_SetCaption;
   23.37 -	device->SetIcon = CGX_SetIcon;
   23.38  	device->IconifyWindow = NULL; /* CGX_IconifyWindow; */
   23.39  	device->GrabInput = NULL /* CGX_GrabInput*/; 
   23.40  	device->GetWMInfo = CGX_GetWMInfo;
   23.41 @@ -211,10 +214,114 @@
   23.42  }
   23.43  
   23.44  VideoBootStrap CGX_bootstrap = {
   23.45 -	"CGX", "Amiga CyberGFX video",
   23.46 -	CGX_Available, CGX_CreateDevice
   23.47 +	"CGX", "AmigaOS CyberGraphics", CGX_Available, CGX_CreateDevice
   23.48  };
   23.49  
   23.50 +#if 0
   23.51 +
   23.52 +/* Create auxiliary (toplevel) windows with the current visual */
   23.53 +static void create_aux_windows(_THIS)
   23.54 +{
   23.55 +    XSetWindowAttributes xattr;
   23.56 +    XWMHints *hints;
   23.57 +    XTextProperty titleprop, iconprop;
   23.58 +    int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen));
   23.59 +
   23.60 +    /* Don't create any extra windows if we are being managed */
   23.61 +    if ( SDL_windowid ) {
   23.62 +	FSwindow = 0;
   23.63 +	WMwindow = strtol(SDL_windowid, NULL, 0);
   23.64 +        return;
   23.65 +    }
   23.66 +
   23.67 +    if(FSwindow)
   23.68 +	XDestroyWindow(SDL_Display, FSwindow);
   23.69 +
   23.70 +    xattr.override_redirect = True;
   23.71 +    xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0;
   23.72 +    xattr.border_pixel = 0;
   23.73 +    xattr.colormap = SDL_XColorMap;
   23.74 +
   23.75 +    FSwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
   23.76 +			     this->hidden->depth, InputOutput, SDL_Visual,
   23.77 +			     CWOverrideRedirect | CWBackPixel | CWBorderPixel
   23.78 +			     | CWColormap,
   23.79 +			     &xattr);
   23.80 +
   23.81 +    XSelectInput(SDL_Display, FSwindow, StructureNotifyMask);
   23.82 +
   23.83 +    /* Tell KDE to keep the fullscreen window on top */
   23.84 +    {
   23.85 +	XEvent ev;
   23.86 +	long mask;
   23.87 +
   23.88 +	memset(&ev, 0, sizeof(ev));
   23.89 +	ev.xclient.type = ClientMessage;
   23.90 +	ev.xclient.window = SDL_Root;
   23.91 +	ev.xclient.message_type = XInternAtom(SDL_Display,
   23.92 +					      "KWM_KEEP_ON_TOP", False);
   23.93 +	ev.xclient.format = 32;
   23.94 +	ev.xclient.data.l[0] = FSwindow;
   23.95 +	ev.xclient.data.l[1] = CurrentTime;
   23.96 +	mask = SubstructureRedirectMask;
   23.97 +	XSendEvent(SDL_Display, SDL_Root, False, mask, &ev);
   23.98 +    }
   23.99 +
  23.100 +    hints = NULL;
  23.101 +    titleprop.value = iconprop.value = NULL;
  23.102 +    if(WMwindow) {
  23.103 +	/* All window attributes must survive the recreation */
  23.104 +	hints = XGetWMHints(SDL_Display, WMwindow);
  23.105 +	XGetWMName(SDL_Display, WMwindow, &titleprop);
  23.106 +	XGetWMIconName(SDL_Display, WMwindow, &iconprop);
  23.107 +	XDestroyWindow(SDL_Display, WMwindow);
  23.108 +    }
  23.109 +
  23.110 +    /* Create the window for windowed management */
  23.111 +    /* (reusing the xattr structure above) */
  23.112 +    WMwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
  23.113 +			     this->hidden->depth, InputOutput, SDL_Visual,
  23.114 +			     CWBackPixel | CWBorderPixel | CWColormap,
  23.115 +			     &xattr);
  23.116 +
  23.117 +    /* Set the input hints so we get keyboard input */
  23.118 +    if(!hints) {
  23.119 +	hints = XAllocWMHints();
  23.120 +	hints->input = True;
  23.121 +	hints->flags = InputHint;
  23.122 +    }
  23.123 +    XSetWMHints(SDL_Display, WMwindow, hints);
  23.124 +    XFree(hints);
  23.125 +    if(titleprop.value) {
  23.126 +	XSetWMName(SDL_Display, WMwindow, &titleprop);
  23.127 +	XFree(titleprop.value);
  23.128 +    }
  23.129 +    if(iconprop.value) {
  23.130 +	XSetWMIconName(SDL_Display, WMwindow, &iconprop);
  23.131 +	XFree(iconprop.value);
  23.132 +    }
  23.133 +
  23.134 +    XSelectInput(SDL_Display, WMwindow,
  23.135 +		 FocusChangeMask | KeyPressMask | KeyReleaseMask
  23.136 +		 | PropertyChangeMask | StructureNotifyMask);
  23.137 +
  23.138 +    /* Set the class hints so we can get an icon (AfterStep) */
  23.139 +    {
  23.140 +	XClassHint *classhints;
  23.141 +	classhints = XAllocClassHint();
  23.142 +	if(classhints != NULL) {
  23.143 +	    classhints->res_name = "SDL_App";
  23.144 +	    classhints->res_class = "SDL_App";
  23.145 +	    XSetClassHint(SDL_Display, WMwindow, classhints);
  23.146 +	    XFree(classhints);
  23.147 +	}
  23.148 +    }
  23.149 +
  23.150 +    /* Allow the window to be deleted by the window manager */
  23.151 +    WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
  23.152 +    XSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1);
  23.153 +}
  23.154 +#endif
  23.155  
  23.156  Uint32 MakeBitMask(_THIS,int type,int format,int *bpp)
  23.157  {
  23.158 @@ -468,6 +575,8 @@
  23.159  	}
  23.160  	SDL_Visual = this->hidden->visuals[i].visual;
  23.161  
  23.162 +//	SDL_XColorMap = SDL_DisplayColormap;
  23.163 +
  23.164  	this->hidden->depth = this->hidden->visuals[i].depth;
  23.165  	D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
  23.166  	vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */
  23.167 @@ -495,6 +604,10 @@
  23.168  		}
  23.169  	}
  23.170  
  23.171 +	/* See if we have been passed a window to use */
  23.172 +/*	SDL_windowid = getenv("SDL_WINDOWID"); */
  23.173 +	SDL_windowid=NULL;
  23.174 +
  23.175  	/* Create the fullscreen and managed windows */
  23.176  //	create_aux_windows(this);
  23.177  
  23.178 @@ -517,45 +630,47 @@
  23.179  
  23.180  void CGX_DestroyWindow(_THIS, SDL_Surface *screen)
  23.181  {
  23.182 -	/* Hide the managed window */
  23.183 -	int was_fullscreen=0;
  23.184 +	if ( ! SDL_windowid ) {
  23.185 +		/* Hide the managed window */
  23.186 +		int was_fullscreen=0;
  23.187  
  23.188 -	if ( screen && (screen->flags & SDL_FULLSCREEN) ) {	
  23.189 -		was_fullscreen=1;
  23.190 -		screen->flags &= ~SDL_FULLSCREEN;
  23.191 -		CGX_LeaveFullScreen(this);
  23.192 -	}
  23.193 +		if ( screen && (screen->flags & SDL_FULLSCREEN) ) {	
  23.194 +			was_fullscreen=1;
  23.195 +			screen->flags &= ~SDL_FULLSCREEN;
  23.196 +//			CGX_LeaveFullScreen(this); tolto x crash
  23.197 +		}
  23.198  
  23.199 -	/* Destroy the output window */
  23.200 -	if ( SDL_Window ) {
  23.201 -		CloseWindow(SDL_Window);
  23.202 -		SDL_Window=NULL;
  23.203 -	}
  23.204 +		/* Destroy the output window */
  23.205 +		if ( SDL_Window ) {
  23.206 +			CloseWindow(SDL_Window);
  23.207 +			SDL_Window=NULL;
  23.208 +		}
  23.209  
  23.210 -	/* Free the colormap entries */
  23.211 -	if ( SDL_XPixels ) {
  23.212 -		int numcolors;
  23.213 -		unsigned long pixel;
  23.214 +		/* Free the colormap entries */
  23.215 +		if ( SDL_XPixels ) {
  23.216 +			int numcolors;
  23.217 +			unsigned long pixel;
  23.218  
  23.219 -		if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen)
  23.220 -		{
  23.221 -			numcolors = 1<<this->screen->format->BitsPerPixel;
  23.222 +			if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen)
  23.223 +			{
  23.224 +				numcolors = 1<<this->screen->format->BitsPerPixel;
  23.225  
  23.226 -			if(numcolors>256)
  23.227 -				numcolors=256;
  23.228 +				if(numcolors>256)
  23.229 +					numcolors=256;
  23.230  
  23.231 -			if(!was_fullscreen&&this->hidden->depth==8)
  23.232 -			{
  23.233 -				for ( pixel=0; pixel<numcolors; pixel++ ) 
  23.234 +				if(!was_fullscreen&&this->hidden->depth==8)
  23.235  				{
  23.236 -					if(SDL_XPixels[pixel]>=0)
  23.237 -						ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]);
  23.238 +					for ( pixel=0; pixel<numcolors; pixel++ ) 
  23.239 +					{
  23.240 +						if(SDL_XPixels[pixel]>=0)
  23.241 +							ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]);
  23.242 +					}
  23.243  				}
  23.244  			}
  23.245 -		}
  23.246 -		free(SDL_XPixels);
  23.247 -		SDL_XPixels = NULL;
  23.248 -	} 
  23.249 +			free(SDL_XPixels);
  23.250 +			SDL_XPixels = NULL;
  23.251 +		} 
  23.252 +	}
  23.253  }
  23.254  
  23.255  static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags)
  23.256 @@ -590,7 +705,13 @@
  23.257  	if ( SDL_Window ) {
  23.258  		CGX_DestroyWindow(this, screen);
  23.259  	}
  23.260 -	SDL_Window = 0;
  23.261 +
  23.262 +	/* See if we have been given a window id */
  23.263 +	if ( SDL_windowid ) {
  23.264 +		SDL_Window = (struct Window *)atol(SDL_windowid);
  23.265 +	} else {
  23.266 +		SDL_Window = 0;
  23.267 +	}
  23.268  
  23.269  	/* find out which visual we are going to use */
  23.270  #if 0
  23.271 @@ -656,6 +777,11 @@
  23.272  	}
  23.273  
  23.274  	/* Create the appropriate colormap */
  23.275 +/*
  23.276 +	if ( SDL_XColorMap != SDL_DisplayColormap ) {
  23.277 +		XFreeColormap(SDL_Display, SDL_XColorMap);
  23.278 +	}
  23.279 +*/
  23.280  	if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) {
  23.281  	    int ncolors;
  23.282  	    D(bug("Alloco XPixels x la palette...\n"));
  23.283 @@ -681,32 +807,70 @@
  23.284  		flags |= SDL_HWPALETTE;
  23.285  
  23.286  	    if ( flags & SDL_HWPALETTE ) {
  23.287 -		screen->flags |= SDL_HWPALETTE;
  23.288 +			screen->flags |= SDL_HWPALETTE;
  23.289 +/*
  23.290 +			SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
  23.291 +		                                SDL_Visual, AllocAll);
  23.292 +*/
  23.293 +	    } else {
  23.294 +/*
  23.295 +			SDL_XColorMap = SDL_DisplayColormap;
  23.296 +*/
  23.297  	    }
  23.298 +	} else {
  23.299 +/*
  23.300 +	    SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
  23.301 +	                                    SDL_Visual, AllocNone);
  23.302 +*/
  23.303  	}
  23.304  
  23.305 +	/* Recreate the auxiliary windows, if needed (required for GL) */
  23.306 +/*
  23.307 +	if ( vis_change )
  23.308 +	    create_aux_windows(this);
  23.309 +*/
  23.310 +
  23.311  	/* resize the (possibly new) window manager window */
  23.312  
  23.313  	/* Create (or use) the X11 display window */
  23.314 -	if ( flags & SDL_OPENGL ) {
  23.315 -		return(-1);
  23.316 -	} else {
  23.317 -		if(flags & SDL_FULLSCREEN)
  23.318 -			SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h,
  23.319 +	if ( !SDL_windowid ) {
  23.320 +		if ( flags & SDL_OPENGL ) {
  23.321 +			return(-1);
  23.322 +		} 
  23.323 +		else 
  23.324 +		{
  23.325 +			if(flags & SDL_FULLSCREEN)
  23.326 +			{
  23.327 +				SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h,
  23.328  											WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE,
  23.329  											WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE,
  23.330  											WA_CustomScreen,(ULONG)SDL_Display,
  23.331  											TAG_DONE);
  23.332 -		else
  23.333 -			SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h,
  23.334 -											WA_Flags,WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR| ((screen->flags&SDL_RESIZABLE) ? WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM : 0),
  23.335 +
  23.336 +				D(bug("Apro finestra backdrop %ldx%ld su %lx!\n",w,h,SDL_Display));
  23.337 +			}
  23.338 +			else
  23.339 +			{
  23.340 +				SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h,
  23.341 +											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))),
  23.342  											WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE,
  23.343  											WA_PubScreen,(ULONG)SDL_Display,
  23.344 -											TAG_DONE);
  23.345 +														TAG_DONE);
  23.346 +				D(bug("Apro finestra %ldx%ld sul wb!\n",w,h));
  23.347 +			}
  23.348 +
  23.349 +		}
  23.350 +		/* Only manage our input if we own the window */
  23.351 +/*
  23.352 +		XSelectInput(SDL_Display, SDL_Window,
  23.353 +					( EnterWindowMask | LeaveWindowMask
  23.354 +					| ButtonPressMask | ButtonReleaseMask
  23.355 +					| PointerMotionMask | ExposureMask ));
  23.356 +*/
  23.357 +
  23.358 +		if(!SDL_Window)
  23.359 +			return -1;
  23.360  	}
  23.361 -	/* Only manage our input if we own the window */
  23.362 -	if(!SDL_Window)
  23.363 -		return -1;
  23.364  
  23.365  	this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX);
  23.366  
  23.367 @@ -736,45 +900,69 @@
  23.368  	if(flags&SDL_HWSURFACE)
  23.369  		screen->flags|=SDL_HWSURFACE;
  23.370  
  23.371 -	CGX_SetSizeHints(this, w, h, flags);
  23.372 -	current_w = w;
  23.373 -	current_h = h;
  23.374 +	if( !SDL_windowid ) {
  23.375 +	    CGX_SetSizeHints(this, w, h, flags);
  23.376 +		current_w = w;
  23.377 +		current_h = h;
  23.378 +	}
  23.379 +
  23.380 +	/* Set our colormaps when not setting a GL mode */
  23.381 +/*
  23.382 +	if ( ! (flags & SDL_OPENGL) ) {
  23.383 +		XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap);
  23.384 +	}
  23.385 +*/
  23.386  
  23.387  	/* Map them both and go fullscreen, if requested */
  23.388 -	if ( flags & SDL_FULLSCREEN ) {
  23.389 -		screen->flags |= SDL_FULLSCREEN;
  23.390 -		currently_fullscreen=1;
  23.391 -//		CGX_EnterFullScreen(this); Ci siamo gia'!
  23.392 -	} else {
  23.393 -		screen->flags &= ~SDL_FULLSCREEN;
  23.394 +	if ( ! SDL_windowid ) {
  23.395 +		if ( flags & SDL_FULLSCREEN ) {
  23.396 +			screen->flags |= SDL_FULLSCREEN;
  23.397 +			currently_fullscreen=1;
  23.398 +//			CGX_EnterFullScreen(this); Ci siamo gia'!
  23.399 +		} else {
  23.400 +			screen->flags &= ~SDL_FULLSCREEN;
  23.401 +		}
  23.402  	}
  23.403 +	screen->w = w;
  23.404 +	screen->h = h;
  23.405 +	screen->pitch = SDL_CalculatePitch(screen);
  23.406 +	CGX_ResizeImage(this, screen, flags);
  23.407 +
  23.408  	return(0);
  23.409  }
  23.410  
  23.411  int CGX_ResizeWindow(_THIS,
  23.412  			SDL_Surface *screen, int w, int h, Uint32 flags)
  23.413  {
  23.414 -	/* Resize the window manager window */
  23.415 -	CGX_SetSizeHints(this, w, h, flags);
  23.416 -	current_w = w;
  23.417 -	current_h = h;
  23.418 +	if ( ! SDL_windowid ) {
  23.419 +		/* Resize the window manager window */
  23.420 +		CGX_SetSizeHints(this, w, h, flags);
  23.421 +		current_w = w;
  23.422 +		current_h = h;
  23.423  
  23.424 -	ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
  23.425 -				h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
  23.426 +		ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
  23.427 +					h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
  23.428  
  23.429 -	/* Resize the fullscreen and display windows */
  23.430 -	if ( flags & SDL_FULLSCREEN ) {
  23.431 -		if ( screen->flags & SDL_FULLSCREEN ) {
  23.432 -			CGX_ResizeFullScreen(this);
  23.433 +		/* Resize the fullscreen and display windows */
  23.434 +/*
  23.435 +		if ( flags & SDL_FULLSCREEN ) {
  23.436 +			if ( screen->flags & SDL_FULLSCREEN ) {
  23.437 +				CGX_ResizeFullScreen(this);
  23.438 +			} else {
  23.439 +				screen->flags |= SDL_FULLSCREEN;
  23.440 +				CGX_EnterFullScreen(this);
  23.441 +			}
  23.442  		} else {
  23.443 -			screen->flags |= SDL_FULLSCREEN;
  23.444 -			CGX_EnterFullScreen(this);
  23.445 +			if ( screen->flags & SDL_FULLSCREEN ) {
  23.446 +				screen->flags &= ~SDL_FULLSCREEN;
  23.447 +				CGX_LeaveFullScreen(this);
  23.448 +			}
  23.449  		}
  23.450 -	} else {
  23.451 -		if ( screen->flags & SDL_FULLSCREEN ) {
  23.452 -			screen->flags &= ~SDL_FULLSCREEN;
  23.453 -			CGX_LeaveFullScreen(this);
  23.454 -		}
  23.455 +*/
  23.456 +		screen->w = w;
  23.457 +		screen->h = h;
  23.458 +		screen->pitch = SDL_CalculatePitch(screen);
  23.459 +		CGX_ResizeImage(this, screen, flags);
  23.460  	}
  23.461  	return(0);
  23.462  }
  23.463 @@ -783,24 +971,51 @@
  23.464  				int width, int height, int bpp, Uint32 flags)
  23.465  {
  23.466  	Uint32 saved_flags;
  23.467 +	int needcreate=0;
  23.468  
  23.469  	/* Lock the event thread, in multi-threading environments */
  23.470  	SDL_Lock_EventThread();
  23.471  
  23.472 +// Check if the window needs to be closed or can be resized
  23.473 +
  23.474 +	if( (flags&SDL_FULLSCREEN) || (current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)))
  23.475 +		needcreate=1;
  23.476 +
  23.477  // Check if we need to close an already existing videomode... 
  23.478  
  23.479  	if(current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN))
  23.480  	{
  23.481 +		unsigned long i;
  23.482  		CGX_DestroyImage(this,current);
  23.483  		CGX_DestroyWindow(this,current);
  23.484  		DestroyScreen(this);
  23.485 +		D(bug("Distrutte immagine, finestra e schermo!\n"));
  23.486 +		GFX_Display=SDL_Display=LockPubScreen(NULL);
  23.487 +
  23.488 +		bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
  23.489 +
  23.490 +		for ( i = 0; i < this->hidden->nvisuals; i++ ) {
  23.491 +			if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */
  23.492 +				break;
  23.493 +		}
  23.494 +		if ( i == this->hidden->nvisuals ) {
  23.495 +			SDL_SetError("No matching visual for requested depth");
  23.496 +			return NULL;	/* should never happen */
  23.497 +		}
  23.498 +		SDL_Visual = this->hidden->visuals[i].visual;
  23.499 +
  23.500 +		D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
  23.501 +		
  23.502  	}
  23.503  	/* Check the combination of flags we were passed */
  23.504  	if ( flags & SDL_FULLSCREEN ) {
  23.505  		int i;
  23.506  	
  23.507  		/* Clear fullscreen flag if not supported */
  23.508 -		if(current->flags&SDL_FULLSCREEN )
  23.509 +		if ( SDL_windowid ) {
  23.510 +			flags &= ~SDL_FULLSCREEN;
  23.511 +		}
  23.512 +		else if(current->flags&SDL_FULLSCREEN )
  23.513  		{
  23.514  			if(current->w!=width ||
  23.515  				current->h!=height ||
  23.516 @@ -930,7 +1145,7 @@
  23.517  	saved_flags = current->flags;
  23.518  
  23.519  	if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL)
  23.520 -	    && bpp == current->format->BitsPerPixel) {
  23.521 +	    && bpp == current->format->BitsPerPixel && !needcreate) {
  23.522  		if (CGX_ResizeWindow(this, current, width, height, flags) < 0) {
  23.523  			current = NULL;
  23.524  			goto done;
  23.525 @@ -942,6 +1157,7 @@
  23.526  		}
  23.527  	}
  23.528  
  23.529 +#if 0
  23.530  	/* Set up the new mode framebuffer */
  23.531  	if ( ((current->w != width) || (current->h != height)) ||
  23.532               ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) {
  23.533 @@ -950,6 +1166,8 @@
  23.534  		current->pitch = SDL_CalculatePitch(current);
  23.535  		CGX_ResizeImage(this, current, flags);
  23.536  	}
  23.537 +#endif
  23.538 +
  23.539  	current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it
  23.540  
  23.541    done:
  23.542 @@ -964,6 +1182,11 @@
  23.543  {
  23.544  	Uint32 event_thread;
  23.545  
  23.546 +	/* Don't switch if we don't own the window */
  23.547 +	if ( SDL_windowid ) {
  23.548 +		return(0);
  23.549 +	}
  23.550 +
  23.551  	/* Don't lock if we are the event thread */
  23.552  	event_thread = SDL_EventThreadID();
  23.553  	if ( event_thread && (SDL_ThreadID() == event_thread) ) {
  23.554 @@ -1090,9 +1313,6 @@
  23.555  
  23.556  	/* Check to make sure we have a colormap allocated */
  23.557  
  23.558 -// It's not needed to reload the whole palette each time on Amiga!
  23.559 -//	ncolors = this->screen->format->palette->ncolors;
  23.560 -
  23.561  	/* It's easy if we have a hidden colormap */
  23.562  	if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) 
  23.563  	{
  23.564 @@ -1104,9 +1324,9 @@
  23.565  //		D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors));
  23.566  
  23.567  		for ( i=0; i<ncolors; i++ ) {
  23.568 -			xcmap[i*3+1] = colors[i].r<<24;
  23.569 -			xcmap[i*3+2] = colors[i].g<<24;
  23.570 -			xcmap[i*3+3] = colors[i].b<<24;
  23.571 +			xcmap[i*3+1] = colors[i+firstcolor].r<<24;
  23.572 +			xcmap[i*3+2] = colors[i+firstcolor].g<<24;
  23.573 +			xcmap[i*3+3] = colors[i+firstcolor].b<<24;
  23.574  		}
  23.575  		xcmap[ncolors*3+1]=0;
  23.576  		LoadRGB32(&GFX_Display->ViewPort,xcmap);
  23.577 @@ -1119,7 +1339,6 @@
  23.578  			return(0);
  23.579  		}
  23.580  
  23.581 -		colors = this->screen->format->palette->colors;
  23.582  		if(this->hidden->depth==8)
  23.583  		{
  23.584  // In this case I have to unalloc and realloc the full palette
  23.585 @@ -1178,6 +1397,22 @@
  23.586  		SDL_VideoSurface=NULL;
  23.587  		CGX_FreeVideoModes(this);
  23.588  
  23.589 +/*
  23.590 +		if ( SDL_iconcolors ) {
  23.591 +			unsigned long pixel;
  23.592 +			int numcolors =
  23.593 +				((this->screen->format)->palette)->ncolors;
  23.594 +			for ( pixel=0; pixel<numcolors; ++pixel ) {
  23.595 +				while ( SDL_iconcolors[pixel] > 0 ) {
  23.596 +					XFreeColors(SDL_Display,
  23.597 +						SDL_DisplayColormap,&pixel,1,0);
  23.598 +					--SDL_iconcolors[pixel];
  23.599 +				}
  23.600 +			}
  23.601 +			free(SDL_iconcolors);
  23.602 +			SDL_iconcolors = NULL;
  23.603 +		} 
  23.604 +*/
  23.605  		/* Free that blank cursor */
  23.606  		if ( SDL_BlankCursor != NULL ) {
  23.607  			FreeMem(SDL_BlankCursor,16);
    24.1 --- a/src/video/cybergfx/SDL_cgxvideo.h	Thu May 10 20:10:54 2001 +0000
    24.2 +++ b/src/video/cybergfx/SDL_cgxvideo.h	Thu May 10 20:13:29 2001 +0000
    24.3 @@ -69,6 +69,8 @@
    24.4      struct Window *SDL_Window;	/* Shared by both displays (no X security?) */
    24.5      unsigned char *BlankCursor;	/* The invisible cursor */
    24.6  
    24.7 +    char *SDL_windowid;		/* Flag: true if we have been passed a window */
    24.8 +
    24.9      /* The variables used for displaying graphics */
   24.10      Uint8 *Ximage;		/* The X image for our window */
   24.11      int swap_pixels;		/* Flag: true if display is swapped endian */
   24.12 @@ -134,6 +136,7 @@
   24.13  #define SDL_Window		(this->hidden->SDL_Window)
   24.14  #define WM_DELETE_WINDOW	(this->hidden->WM_DELETE_WINDOW)
   24.15  #define SDL_BlankCursor		(this->hidden->BlankCursor)
   24.16 +#define SDL_windowid		(this->hidden->SDL_windowid)
   24.17  #define SDL_Ximage		(this->hidden->Ximage)
   24.18  #define SDL_GC			(this->hidden->gc)
   24.19  #define swap_pixels		(this->hidden->swap_pixels)
   24.20 @@ -152,6 +155,9 @@
   24.21  #define SDL_XPixels		(this->hidden->XPixels)
   24.22  #define SDL_iconcolors		(this->hidden->iconcolors)
   24.23  
   24.24 +/* Used to get the X cursor from a window-manager specific cursor */
   24.25 +// extern Cursor SDL_GetWMXCursor(WMcursor *cursor);
   24.26 +
   24.27  extern int CGX_CreateWindow(_THIS, SDL_Surface *screen,
   24.28  			    int w, int h, int bpp, Uint32 flags);
   24.29  extern int CGX_ResizeWindow(_THIS,
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/src/video/cybergfx/SDL_cgxyuv.c	Thu May 10 20:13:29 2001 +0000
    25.3 @@ -0,0 +1,191 @@
    25.4 +/*
    25.5 +    SDL - Simple DirectMedia Layer
    25.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  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 Library General Public
   25.10 +    License as published by the Free Software Foundation; either
   25.11 +    version 2 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 +    Library General Public License for more details.
   25.17 +
   25.18 +    You should have received a copy of the GNU Library General Public
   25.19 +    License along with this library; if not, write to the Free
   25.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   25.21 +
   25.22 +    Sam Lantinga
   25.23 +    slouken@devolution.com
   25.24 +*/
   25.25 +
   25.26 +#ifdef SAVE_RCSID
   25.27 +static char rcsid =
   25.28 + "@(#) $Id$";
   25.29 +#endif
   25.30 +
   25.31 +/* This is the XFree86 Xv extension implementation of YUV video overlays */
   25.32 +
   25.33 +#ifdef XFREE86_XV
   25.34 +
   25.35 +#include <stdlib.h>
   25.36 +#include <string.h>
   25.37 +#include <X11/Xlib.h>
   25.38 +#include <sys/ipc.h>
   25.39 +#include <sys/shm.h>
   25.40 +#include <X11/extensions/XShm.h>
   25.41 +#include <X11/extensions/Xvlib.h>
   25.42 +
   25.43 +#include "SDL_error.h"
   25.44 +#include "SDL_video.h"
   25.45 +#include "SDL_x11yuv_c.h"
   25.46 +#include "SDL_yuvfuncs.h"
   25.47 +
   25.48 +/* The functions used to manipulate software video overlays */
   25.49 +static struct private_yuvhwfuncs x11_yuvfuncs = {
   25.50 +	X11_LockYUVOverlay,
   25.51 +	X11_UnlockYUVOverlay,
   25.52 +	X11_DisplayYUVOverlay,
   25.53 +	X11_FreeYUVOverlay
   25.54 +};
   25.55 +
   25.56 +struct private_yuvhwdata {
   25.57 +	int port;
   25.58 +	XShmSegmentInfo yuvshm;
   25.59 +	XvImage *image;
   25.60 +};
   25.61 +
   25.62 +
   25.63 +SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
   25.64 +{
   25.65 +	SDL_Overlay *overlay;
   25.66 +	struct private_yuvhwdata *hwdata;
   25.67 +	int xv_port;
   25.68 +	int i, j;
   25.69 +	int adaptors;
   25.70 +	XvAdaptorInfo *ainfo;
   25.71 +	XShmSegmentInfo *yuvshm;
   25.72 +
   25.73 +	xv_port = -1;
   25.74 +	if ( (Success == XvQueryExtension(GFX_Display, &j, &j, &j, &j, &j)) &&
   25.75 +	     (Success == XvQueryAdaptors(GFX_Display,
   25.76 +	                                 RootWindow(GFX_Display, SDL_Screen),
   25.77 +	                                 &adaptors, &ainfo)) ) {
   25.78 +		for ( i=0; (i<adaptors) && (xv_port == -1); ++i ) {
   25.79 +			if ( (ainfo[i].type & XvInputMask) &&
   25.80 +			     (ainfo[i].type & XvImageMask) ) {
   25.81 +				int num_formats;
   25.82 +				XvImageFormatValues *formats;
   25.83 +				formats = XvListImageFormats(GFX_Display,
   25.84 +				              ainfo[i].base_id, &num_formats);
   25.85 +				for ( j=0; j<num_formats; ++j ) {
   25.86 +					if ( (Uint32)formats[j].id == format ) {
   25.87 +						xv_port = ainfo[i].base_id;
   25.88 +						break;
   25.89 +					}
   25.90 +				}
   25.91 +			}
   25.92 +		}
   25.93 +	}
   25.94 +	if ( xv_port == -1 ) {
   25.95 +		SDL_SetError("No available video ports for requested format");
   25.96 +		return(NULL);
   25.97 +	}
   25.98 +
   25.99 +	/* Create the overlay structure */
  25.100 +	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
  25.101 +	if ( overlay == NULL ) {
  25.102 +		SDL_OutOfMemory();
  25.103 +		return(NULL);
  25.104 +	}
  25.105 +	memset(overlay, 0, (sizeof *overlay));
  25.106 +
  25.107 +	/* Fill in the basic members */
  25.108 +	overlay->format = format;
  25.109 +	overlay->w = width;
  25.110 +	overlay->h = height;
  25.111 +
  25.112 +	/* Set up the YUV surface function structure */
  25.113 +	overlay->hwfuncs = &x11_yuvfuncs;
  25.114 +
  25.115 +	/* Create the pixel data and lookup tables */
  25.116 +	hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
  25.117 +	overlay->hwdata = hwdata;
  25.118 +	if ( hwdata == NULL ) {
  25.119 +		SDL_OutOfMemory();
  25.120 +		SDL_FreeYUVOverlay(overlay);
  25.121 +		return(NULL);
  25.122 +	}
  25.123 +	yuvshm = &hwdata->yuvshm;
  25.124 +	memset(yuvshm, 0, sizeof(*yuvshm));
  25.125 +	hwdata->port = xv_port;
  25.126 +	hwdata->image = XvShmCreateImage(GFX_Display, xv_port, format,
  25.127 +	                                 0, width, height, yuvshm);
  25.128 +	if ( hwdata->image == NULL ) {
  25.129 +		SDL_OutOfMemory();
  25.130 +		SDL_FreeYUVOverlay(overlay);
  25.131 +		return(NULL);
  25.132 +	}
  25.133 +	yuvshm->shmid = shmget(IPC_PRIVATE, hwdata->image->data_size,
  25.134 +	                       IPC_CREAT | 0777);
  25.135 +	if ( yuvshm->shmid < 0 ) {
  25.136 +		SDL_SetError("Unable to get %d bytes shared memory",
  25.137 +		             hwdata->image->data_size);
  25.138 +		SDL_FreeYUVOverlay(overlay);
  25.139 +		return(NULL);
  25.140 +	}
  25.141 +	yuvshm->shmaddr  = (caddr_t) shmat(yuvshm->shmid, 0, 0);
  25.142 +	yuvshm->readOnly = False;
  25.143 +	hwdata->image->data = yuvshm->shmaddr;
  25.144 +
  25.145 +	XShmAttach(GFX_Display, yuvshm);
  25.146 +	XSync(GFX_Display, False);
  25.147 +	shmctl(yuvshm->shmid, IPC_RMID, 0);
  25.148 +
  25.149 +	/* We're all done.. */
  25.150 +	return(overlay);
  25.151 +}
  25.152 +
  25.153 +int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
  25.154 +{
  25.155 +	overlay->pixels = overlay->hwdata->image->data;
  25.156 +	/* What should the pitch be set to? */
  25.157 +	return(0);
  25.158 +}
  25.159 +
  25.160 +void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay)
  25.161 +{
  25.162 +	overlay->pixels = NULL;
  25.163 +}
  25.164 +
  25.165 +int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
  25.166 +{
  25.167 +	struct private_yuvhwdata *hwdata;
  25.168 +
  25.169 +	hwdata = overlay->hwdata;
  25.170 +	XvShmPutImage(GFX_Display, hwdata->port, SDL_Window, SDL_GC,
  25.171 +	              hwdata->image, 0, 0, overlay->w, overlay->h,
  25.172 +	              dstrect->x, dstrect->y, dstrect->w, dstrect->h, False);
  25.173 +	XSync(GFX_Display, False);
  25.174 +	return(0);
  25.175 +}
  25.176 +
  25.177 +void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
  25.178 +{
  25.179 +	struct private_yuvhwdata *hwdata;
  25.180 +
  25.181 +	hwdata = overlay->hwdata;
  25.182 +	if ( hwdata ) {
  25.183 +		if ( hwdata->yuvshm.shmaddr ) {
  25.184 +			XShmDetach(GFX_Display, &hwdata->yuvshm);
  25.185 +			shmdt(hwdata->yuvshm.shmaddr);
  25.186 +		}
  25.187 +		if ( hwdata->image ) {
  25.188 +			XFree(hwdata->image);
  25.189 +		}
  25.190 +		free(hwdata);
  25.191 +	}
  25.192 +}
  25.193 +
  25.194 +#endif /* XFREE86_XV */
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/src/video/cybergfx/SDL_cgxyuv_c.h	Thu May 10 20:13:29 2001 +0000
    26.3 @@ -0,0 +1,45 @@
    26.4 +/*
    26.5 +    SDL - Simple DirectMedia Layer
    26.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  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 Library General Public
   26.10 +    License as published by the Free Software Foundation; either
   26.11 +    version 2 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 +    Library General Public License for more details.
   26.17 +
   26.18 +    You should have received a copy of the GNU Library General Public
   26.19 +    License along with this library; if not, write to the Free
   26.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   26.21 +
   26.22 +    Sam Lantinga
   26.23 +    slouken@devolution.com
   26.24 +*/
   26.25 +
   26.26 +#ifdef SAVE_RCSID
   26.27 +static char rcsid =
   26.28 + "@(#) $Id$";
   26.29 +#endif
   26.30 +
   26.31 +/* This is the XFree86 Xv extension implementation of YUV video overlays */
   26.32 +
   26.33 +#include "SDL_video.h"
   26.34 +#include "SDL_cgxvideo.h"
   26.35 +
   26.36 +#ifdef XFREE86_XV
   26.37 +
   26.38 +extern SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
   26.39 +
   26.40 +extern int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay);
   26.41 +
   26.42 +extern void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay);
   26.43 +
   26.44 +extern int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect);
   26.45 +
   26.46 +extern void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay);
   26.47 +
   26.48 +#endif /* XFREE86_XV */
    27.1 --- a/src/video/default_cursor.h	Thu May 10 20:10:54 2001 +0000
    27.2 +++ b/src/video/default_cursor.h	Thu May 10 20:13:29 2001 +0000
    27.3 @@ -1,6 +1,6 @@
    27.4  /*
    27.5      SDL - Simple DirectMedia Layer
    27.6 -    Copyright (C) 1997, 1998, 1999, 2000  Sam Lantinga
    27.7 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    27.8  
    27.9      This library is free software; you can redistribute it and/or
   27.10      modify it under the terms of the GNU Library General Public