Updated Amiga port by Gabriele Greco
authorSam Lantinga <slouken@libsdl.org>
Sun, 16 Dec 2001 20:00:27 +0000
changeset 255dcb5e869f8b5
parent 254 4fc12b8edf74
child 256 640dcf27d2f7
Updated Amiga port by Gabriele Greco
src/audio/amigaos/SDL_ahiaudio.c
src/audio/amigaos/SDL_ahiaudio.h
src/joystick/amigaos/SDL_sysjoystick.c
src/thread/amigaos/SDL_syssem.c
src/thread/amigaos/SDL_systhread.c
src/thread/amigaos/SDL_systhread_c.h
src/timer/amigaos/SDL_systimer.c
src/video/cybergfx/SDL_amigaevents.c
src/video/cybergfx/SDL_cgxaccel.c
src/video/cybergfx/SDL_cgxgl.c
src/video/cybergfx/SDL_cgxgl_c.h
src/video/cybergfx/SDL_cgximage.c
src/video/cybergfx/SDL_cgxmodes.c
src/video/cybergfx/SDL_cgxvideo.c
src/video/cybergfx/SDL_cgxvideo.h
     1.1 --- a/src/audio/amigaos/SDL_ahiaudio.c	Fri Dec 14 13:13:20 2001 +0000
     1.2 +++ b/src/audio/amigaos/SDL_ahiaudio.c	Sun Dec 16 20:00:27 2001 +0000
     1.3 @@ -29,10 +29,6 @@
     1.4  
     1.5  /* Allow access to a raw mixing buffer (for AmigaOS) */
     1.6  
     1.7 -#include <stdio.h>
     1.8 -#include <stdlib.h>
     1.9 -#include <string.h>
    1.10 -
    1.11  #include "SDL_endian.h"
    1.12  #include "SDL_audio.h"
    1.13  #include "SDL_audiomem.h"
     2.1 --- a/src/audio/amigaos/SDL_ahiaudio.h	Fri Dec 14 13:13:20 2001 +0000
     2.2 +++ b/src/audio/amigaos/SDL_ahiaudio.h	Sun Dec 16 20:00:27 2001 +0000
     2.3 @@ -35,6 +35,8 @@
     2.4  #else
     2.5  #include <inline/exec.h>
     2.6  #endif
     2.7 +#include <stdlib.h>
     2.8 +#include <string.h>
     2.9  
    2.10  #include <devices/ahi.h>
    2.11  #include "mydebug.h"
    2.12 @@ -47,7 +49,7 @@
    2.13  	/* The handle for the audio device */
    2.14  	struct AHIRequest *audio_req[2];
    2.15  	struct MsgPort *audio_port;
    2.16 -	Sint32 freq,type,bytespersample;
    2.17 +	Sint32 freq,type,bytespersample,size;
    2.18  	Uint8 *mixbuf[2];           /* The app mixing buffer */
    2.19  	int current_buffer;
    2.20  	Uint32 playing;
     3.1 --- a/src/joystick/amigaos/SDL_sysjoystick.c	Fri Dec 14 13:13:20 2001 +0000
     3.2 +++ b/src/joystick/amigaos/SDL_sysjoystick.c	Sun Dec 16 20:00:27 2001 +0000
     3.3 @@ -31,7 +31,7 @@
     3.4  #include <stdio.h>		/* For the definition of NULL */
     3.5  
     3.6  #include <libraries/lowlevel.h>
     3.7 -#ifdef __SASC
     3.8 +#if defined(__SASC) || defined(STORMC4_WOS)
     3.9  #include <proto/exec.h>
    3.10  #include <proto/lowlevel.h>
    3.11  #include <proto/graphics.h>
    3.12 @@ -72,7 +72,7 @@
    3.13  	JPF_BUTTON_REVERSE,
    3.14  };
    3.15  
    3.16 -struct joystick_hwdata 
    3.17 +struct joystick_hwdata
    3.18  {
    3.19  	ULONG joystate;
    3.20  };
    3.21 @@ -128,7 +128,7 @@
    3.22  
    3.23  	for(i=0;i<20;i++)
    3.24  	{
    3.25 -		temp=ReadJoyPort(joystick->index);
    3.26 +		temp=ReadJoyPort(joystick->index^1); // fix to invert amiga joyports
    3.27  		WaitTOF();
    3.28  	}
    3.29  
    3.30 @@ -152,7 +152,7 @@
    3.31   */
    3.32  void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
    3.33  {
    3.34 -	ULONG data;	
    3.35 +	ULONG data;
    3.36  	int i;
    3.37  
    3.38  	if(joystick->index<2)
     4.1 --- a/src/thread/amigaos/SDL_syssem.c	Fri Dec 14 13:13:20 2001 +0000
     4.2 +++ b/src/thread/amigaos/SDL_syssem.c	Sun Dec 16 20:00:27 2001 +0000
     4.3 @@ -61,7 +61,7 @@
     4.4  	memset(sem,0,sizeof(*sem));
     4.5  
     4.6  	InitSemaphore(&sem->Sem);
     4.7 -	
     4.8 +
     4.9  	return(sem);
    4.10  }
    4.11  
    4.12 @@ -143,10 +143,14 @@
    4.13  Uint32 SDL_SemValue(SDL_sem *sem)
    4.14  {
    4.15  	Uint32 value;
    4.16 -	
    4.17 +
    4.18  	value = 0;
    4.19  	if ( sem ) {
    4.20 +		#ifdef STORMC4_WOS
    4.21 +		value = sem->Sem.ssppc_SS.ss_NestCount;
    4.22 +		#else
    4.23  		value = sem->Sem.ss_NestCount;
    4.24 +		#endif
    4.25  //		SDL_UnlockMutex(sem->count_lock);
    4.26  	}
    4.27  	return value;
     5.1 --- a/src/thread/amigaos/SDL_systhread.c	Fri Dec 14 13:13:20 2001 +0000
     5.2 +++ b/src/thread/amigaos/SDL_systhread.c	Sun Dec 16 20:00:27 2001 +0000
     5.3 @@ -32,6 +32,7 @@
     5.4  #include "SDL_thread.h"
     5.5  #include "SDL_thread_c.h"
     5.6  #include "SDL_systhread.h"
     5.7 +#include "mydebug.h"
     5.8  
     5.9  typedef struct {
    5.10  	int (*func)(void *);
    5.11 @@ -47,10 +48,15 @@
    5.12  #elif defined(__PPC__)
    5.13  Uint32 RunThread(char *args)
    5.14  #else
    5.15 -Uint32 RunThread(char *args __asm("a0") )
    5.16 +Uint32 __saveds RunThread(char *args __asm("a0") )
    5.17  #endif
    5.18  {
    5.19 +	#ifdef STORMC4_WOS
    5.20 +	thread_args *data=(thread_args *)args;
    5.21 +	#else
    5.22  	thread_args *data=(thread_args *)atol(args);
    5.23 +	#endif
    5.24 +
    5.25  	struct Task *Father;
    5.26  
    5.27  	D(bug("Received data: %lx\n",data));
    5.28 @@ -59,6 +65,7 @@
    5.29  	SDL_RunThread(data);
    5.30  
    5.31  	Signal(Father,SIGBREAKF_CTRL_F);
    5.32 +	D(bug("Thread with data %lx ended\n",data));
    5.33  	return(0);
    5.34  }
    5.35  
    5.36 @@ -68,7 +75,7 @@
    5.37  
    5.38  Uint32 RunTheThread(void)
    5.39  {
    5.40 -	thread_args *data=(thread_args *)atol(REG_A0);
    5.41 +	thread_args *data=(thread_args *)atol((char *)REG_A0);
    5.42  	struct Task *Father;
    5.43  
    5.44  	D(bug("Received data: %lx\n",data));
    5.45 @@ -77,16 +84,18 @@
    5.46  	SDL_RunThread(data);
    5.47  
    5.48  	Signal(Father,SIGBREAKF_CTRL_F);
    5.49 +	D(bug("Thread with data %lx ended\n",data));
    5.50  	return(0);
    5.51  }
    5.52  
    5.53 -struct EmulLibEntry RunThread=
    5.54 +struct EmulLibEntry RunThreadStruct=
    5.55  {
    5.56  	TRAP_LIB,
    5.57  	0,
    5.58 -	RunTheThread
    5.59 +	(ULONG)RunTheThread
    5.60  };
    5.61  
    5.62 +void *RunThread=&RunThreadStruct;
    5.63  #endif
    5.64  
    5.65  
    5.66 @@ -100,7 +109,14 @@
    5.67  	if(args)
    5.68  		sprintf(buffer,"%ld",args);
    5.69  
    5.70 -
    5.71 +	#ifdef STORMC4_WOS
    5.72 +	thread->handle=CreateTaskPPCTags(TASKATTR_CODE,	RunThread,
    5.73 +					TASKATTR_NAME,	"SDL subtask",
    5.74 +					TASKATTR_STACKSIZE, 100000,
    5.75 +					(args ? TASKATTR_R3 : TAG_IGNORE), args,
    5.76 +					TASKATTR_INHERITR2, TRUE,
    5.77 +					TAG_DONE);
    5.78 +	#else
    5.79  	thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(),
    5.80  					NP_Name,(ULONG)"SDL subtask",
    5.81  					NP_CloseOutput, FALSE,
    5.82 @@ -108,6 +124,8 @@
    5.83  					NP_Entry,(ULONG)RunThread,
    5.84  					args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer,
    5.85  					TAG_DONE);
    5.86 +	#endif
    5.87 +
    5.88  	if(!thread->handle)
    5.89  	{
    5.90  		SDL_SetError("Not enough resources to create thread");
     6.1 --- a/src/thread/amigaos/SDL_systhread_c.h	Fri Dec 14 13:13:20 2001 +0000
     6.2 +++ b/src/thread/amigaos/SDL_systhread_c.h	Sun Dec 16 20:00:27 2001 +0000
     6.3 @@ -28,7 +28,7 @@
     6.4  #include <exec/exec.h>
     6.5  #include <dos/dos.h>
     6.6  #include <dos/dostags.h>
     6.7 -#ifdef __SASC
     6.8 +#if defined (__SASC) || defined(STORMC4_WOS)
     6.9  #include <proto/dos.h>
    6.10  #include <proto/exec.h>
    6.11  #else
    6.12 @@ -44,5 +44,25 @@
    6.13  extern struct ExecBase *SysBase;
    6.14  extern struct DosLibrary *DOSBase;
    6.15  
    6.16 +#ifdef STORMC4_WOS
    6.17 +#include <proto/powerpc.h>
    6.18 +
    6.19 +/* use powerpc.library functions instead og exec */
    6.20 +#define SYS_ThreadHandle struct TaskPPC *
    6.21 +#define Signal SignalPPC
    6.22 +#define Wait WaitPPC
    6.23 +#define Task TaskPPC
    6.24 +#define FindTask FindTaskPPC
    6.25 +#define SetSignal SetSignalPPC
    6.26 +
    6.27 +#define InitSemaphore InitSemaphorePPC
    6.28 +#define ObtainSemaphore ObtainSemaphorePPC
    6.29 +#define AttemptSemaphore AttemptSemaphorePPC
    6.30 +#define ReleaseSemaphore ReleaseSemaphorePPC
    6.31 +#define SignalSemaphore SignalSemaphorePPC
    6.32 +
    6.33 +#else
    6.34 +
    6.35  #define SYS_ThreadHandle struct Task *
    6.36 +#endif /*STORMC4_WOS*/
    6.37  
     7.1 --- a/src/timer/amigaos/SDL_systimer.c	Fri Dec 14 13:13:20 2001 +0000
     7.2 +++ b/src/timer/amigaos/SDL_systimer.c	Sun Dec 16 20:00:27 2001 +0000
     7.3 @@ -38,6 +38,10 @@
     7.4  #include <pragmas/graphics.h>
     7.5  #include <clib/exec_protos.h>
     7.6  #include <pragmas/exec.h>
     7.7 +#elif defined(STORMC4_WOS)
     7.8 +#include <proto/dos.h>
     7.9 +#include <proto/exec.h>
    7.10 +#include <proto/graphics.h>
    7.11  #else
    7.12  #include <inline/dos.h>
    7.13  #include <inline/exec.h>
    7.14 @@ -59,7 +63,7 @@
    7.15  
    7.16  /* The first ticks value of the application */
    7.17  
    7.18 -#ifndef __PPC__
    7.19 +#if !defined(__PPC__) || defined(STORMC4_WOS) || defined(MORPHOS)
    7.20  static clock_t start;
    7.21  
    7.22  void SDL_StartTicks(void)
    7.23 @@ -120,7 +124,7 @@
    7.24  	/* Set first ticks value */
    7.25  	if(!MyTimer)
    7.26  		PPC_TimerInit();
    7.27 -	
    7.28 +
    7.29  	PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,start);
    7.30  	start[1]>>=10;
    7.31  	start[1]|=((result[0]&0x3ff)<<22);
    7.32 @@ -134,7 +138,7 @@
    7.33  
    7.34  //	PPCAsr64p(result,10);
    7.35  // Non va, la emulo:
    7.36 -	
    7.37 +
    7.38  	result[1]>>=10;
    7.39  	result[1]|=((result[0]&0x3ff)<<22);
    7.40  
    7.41 @@ -200,7 +204,7 @@
    7.42  	else
    7.43  	{
    7.44  		D(bug("Errore nell'inizializzazione del timer!\n"));
    7.45 -	}	
    7.46 +	}
    7.47  }
    7.48  
    7.49  #endif
    7.50 @@ -234,7 +238,7 @@
    7.51  /* This is only called if the event thread is not running */
    7.52  int SDL_SYS_TimerInit(void)
    7.53  {
    7.54 -	D(bug("Creo il thread per il timer (NOITMER)...\n"));
    7.55 +	D(bug("Creating thread for the timer (NOITIMER)...\n"));
    7.56  
    7.57  	timer_alive = 1;
    7.58  	timer_thread = SDL_CreateThread(RunTimer, NULL);
     8.1 --- a/src/video/cybergfx/SDL_amigaevents.c	Fri Dec 14 13:13:20 2001 +0000
     8.2 +++ b/src/video/cybergfx/SDL_amigaevents.c	Sun Dec 16 20:00:27 2001 +0000
     8.3 @@ -148,7 +148,7 @@
     8.4  			break;
     8.5  #if 0
     8.6  	    /* Gaining input focus? */
     8.7 -	    case IDCMP_ACTIVEWINDOW: 
     8.8 +	    case IDCMP_ACTIVEWINDOW:
     8.9  			posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
    8.10  
    8.11  			/* Queue entry into fullscreen mode */
    8.12 @@ -166,7 +166,7 @@
    8.13  		    break;
    8.14  #endif
    8.15  	    /* Mouse motion? */
    8.16 -	    case IDCMP_MOUSEMOVE: 
    8.17 +	    case IDCMP_MOUSEMOVE:
    8.18  			if ( SDL_VideoSurface ) {
    8.19  				posted = SDL_PrivateMouseMotion(0, 0,
    8.20  						msg->MouseX-SDL_Window->BorderLeft,
    8.21 @@ -179,14 +179,14 @@
    8.22  
    8.23  			if(!(code&IECODE_UP_PREFIX))
    8.24  			{
    8.25 -				posted = SDL_PrivateMouseButton(SDL_PRESSED, 
    8.26 +				posted = SDL_PrivateMouseButton(SDL_PRESSED,
    8.27  						amiga_GetButton(code), 0, 0);
    8.28  			    }
    8.29  	    /* Mouse button release? */
    8.30  			else
    8.31  			{
    8.32  				code&=~IECODE_UP_PREFIX;
    8.33 -				posted = SDL_PrivateMouseButton(SDL_RELEASED, 
    8.34 +				posted = SDL_PrivateMouseButton(SDL_RELEASED,
    8.35  						amiga_GetButton(code), 0, 0);
    8.36  			}
    8.37  			break;
    8.38 @@ -211,7 +211,7 @@
    8.39  			/* Check to see if this is a repeated key */
    8.40  /*			if ( ! X11_KeyRepeat(SDL_Display, &xevent) )  */
    8.41  
    8.42 -				posted = SDL_PrivateKeyboard(SDL_RELEASED, 
    8.43 +				posted = SDL_PrivateKeyboard(SDL_RELEASED,
    8.44  					amiga_TranslateKey(code, &keysym));
    8.45  		    }
    8.46  		    break;
    8.47 @@ -235,7 +235,7 @@
    8.48  		posted = SDL_PrivateAppActive(1, SDL_APPACTIVE);
    8.49  
    8.50  		if ( SDL_VideoSurface &&
    8.51 -		     (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) 
    8.52 +		     (SDL_VideoSurface->flags & SDL_FULLSCREEN) )
    8.53  		{
    8.54  			CGX_EnterFullScreen(this);
    8.55  		} else {
    8.56 @@ -254,9 +254,10 @@
    8.57  #endif
    8.58  
    8.59  	    /* Have we been resized? */
    8.60 -	    case IDCMP_NEWSIZE: 
    8.61 +	    case IDCMP_NEWSIZE:
    8.62  			SDL_PrivateResize(SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight,
    8.63  		                  SDL_Window->Height-SDL_Window->BorderTop-SDL_Window->BorderBottom);
    8.64 +
    8.65  			break;
    8.66  
    8.67  	    /* Have we been requested to quit? */
    8.68 @@ -428,7 +429,11 @@
    8.69  
    8.70  SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym)
    8.71  {
    8.72 +	#ifdef STORMC4_WOS
    8.73 +	static struct Library *KeymapBase=NULL; /* Linking failed in WOS version if ConsoleDevice was used */
    8.74 +	#else
    8.75  	static struct Library *ConsoleDevice=NULL;
    8.76 +	#endif
    8.77  
    8.78  	/* Get the raw keyboard scancode */
    8.79  	keysym->scancode = code;
    8.80 @@ -438,10 +443,17 @@
    8.81  	fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode);
    8.82  #endif
    8.83  	/* Get the translated SDL virtual keysym */
    8.84 -	if ( keysym->sym==SDLK_UNKNOWN ) 
    8.85 +	if ( keysym->sym==SDLK_UNKNOWN )
    8.86  	{
    8.87 +		#ifdef STORMC4_WOS
    8.88 +		if(!KeymapBase)
    8.89 +		#else
    8.90  		if(!ConsoleDevice)
    8.91 +		#endif
    8.92  		{
    8.93 +			#ifdef STORMC4_WOS
    8.94 +			KeymapBase=OpenLibrary("keymap.library", 0L);
    8.95 +			#else
    8.96  			if(ConPort=CreateMsgPort())
    8.97  			{
    8.98  				if(ConReq=CreateIORequest(ConPort,sizeof(struct IOStdReq)))
    8.99 @@ -460,9 +472,14 @@
   8.100  					ConPort=NULL;
   8.101  				}
   8.102  			}
   8.103 +			#endif
   8.104  		}
   8.105  
   8.106 +		#ifdef STORMC4_WOS
   8.107 +		if(KeymapBase)
   8.108 +		#else
   8.109  		if(ConsoleDevice)
   8.110 +		#endif
   8.111  		{
   8.112  			struct InputEvent event;
   8.113  			long actual;
   8.114 @@ -477,7 +494,11 @@
   8.115  			event.ie_NextEvent=NULL;
   8.116  			event.ie_Prev1DownCode=event.ie_Prev1DownQual=event.ie_Prev2DownCode=event.ie_Prev2DownQual=0;
   8.117  
   8.118 +			#ifdef STORMC4_WOS
   8.119 +			if( (actual=MapRawKey(&event,buffer,5,NULL))>=0)
   8.120 +			#else
   8.121  			if( (actual=RawKeyConvert(&event,buffer,5,NULL))>=0)
   8.122 +			#endif
   8.123  			{
   8.124  				if(actual>1)
   8.125  				{
     9.1 --- a/src/video/cybergfx/SDL_cgxaccel.c	Fri Dec 14 13:13:20 2001 +0000
     9.2 +++ b/src/video/cybergfx/SDL_cgxaccel.c	Sun Dec 16 20:00:27 2001 +0000
     9.3 @@ -1,3 +1,30 @@
     9.4 +/*
     9.5 +    SDL - Simple DirectMedia Layer
     9.6 +    Copyright (C) 1997, 1998, 1999, 2000  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@libsdl.org
    9.24 +*/
    9.25 +
    9.26 +#ifdef SAVE_RCSID
    9.27 +static char rcsid =
    9.28 + "@(#) $Id$";
    9.29 +#endif
    9.30 +
    9.31  #include "SDL_error.h"
    9.32  #include "SDL_endian.h"
    9.33  #include "SDL_sysvideo.h"
    9.34 @@ -10,7 +37,7 @@
    9.35  
    9.36  // These are needed to avoid register troubles with gcc -O2!
    9.37  
    9.38 -#if defined(__SASC) || defined(__PPC__)
    9.39 +#if defined(__SASC) || defined(__PPC__) || defined(MORPHOS)
    9.40  #define BMKBRP(a,b,c,d,e,f,g,h,i,j) BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j)
    9.41  #define	BBRP(a,b,c,d,e,f,g,h,i) BltBitMapRastPort(a,b,c,d,e,f,g,h,i)
    9.42  #define BBB(a,b,c,d,e,f,g,h,i,j,k) BltBitMap(a,b,c,d,e,f,g,h,i,j,k)
    9.43 @@ -18,10 +45,10 @@
    9.44  void BMKBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,APTR j)
    9.45  {BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j);}
    9.46  
    9.47 -void BBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i) 
    9.48 +void BBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i)
    9.49  {BltBitMapRastPort(a,b,c,d,e,f,g,h,i);}
    9.50  
    9.51 -void BBB(struct BitMap *a,WORD b, WORD c,struct BitMap *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,UBYTE j,UWORD *k) 
    9.52 +void BBB(struct BitMap *a,WORD b, WORD c,struct BitMap *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,UBYTE j,UWORD *k)
    9.53  {BltBitMap(a,b,c,d,e,f,g,h,i,j,k);}
    9.54  #endif
    9.55  
    9.56 @@ -39,7 +66,7 @@
    9.57  
    9.58  			memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h));
    9.59  
    9.60 -			D(bug("Costruisco colorkey: colore: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n",key,surface->w,surface->h,RASSIZE(surface->w,surface->h),surface->format->BytesPerPixel));
    9.61 +			D(bug("Building colorkey mask: color: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n",key,surface->w,surface->h,RASSIZE(surface->w,surface->h),surface->format->BytesPerPixel));
    9.62  
    9.63  			if(lock=LockBitMapTags(surface->hwdata->bmap,LBMI_BASEADDRESS,(ULONG)&surface->pixels,
    9.64  					LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))
    9.65 @@ -138,7 +165,7 @@
    9.66  						ok=-1;
    9.67  				}
    9.68  				UnLockBitMap(lock);
    9.69 -				D(bug("...Colorkey costruito!\n"));
    9.70 +				D(bug("...Colorkey built!\n"));
    9.71  				return ok;
    9.72  			}
    9.73  		}
    10.1 --- a/src/video/cybergfx/SDL_cgxgl.c	Fri Dec 14 13:13:20 2001 +0000
    10.2 +++ b/src/video/cybergfx/SDL_cgxgl.c	Sun Dec 16 20:00:27 2001 +0000
    10.3 @@ -25,189 +25,117 @@
    10.4   "@(#) $Id$";
    10.5  #endif
    10.6  
    10.7 -// #include <stdlib.h>	/* For getenv() prototype */
    10.8 -// #include <string.h>
    10.9 +/* StormMesa implementation of SDL OpenGL support */
   10.10  
   10.11 -#include "SDL_events_c.h"
   10.12  #include "SDL_error.h"
   10.13 +#include "SDL_cgxgl_c.h"
   10.14  #include "SDL_cgxvideo.h"
   10.15 -#include "SDL_cgxgl_c.h"
   10.16  
   10.17 -#define DEFAULT_OPENGL	"libGL.so.1"
   10.18 +#ifdef HAVE_OPENGL
   10.19 +AmigaMesaContext glcont=NULL;
   10.20 +#endif
   10.21  
   10.22 -/* return the preferred visual to use for openGL graphics */
   10.23 -void *CGX_GL_GetVisual(_THIS)
   10.24 +/* Init OpenGL */
   10.25 +int CGX_GL_Init(_THIS)
   10.26  {
   10.27  #ifdef HAVE_OPENGL
   10.28 -	/* 64 seems nice. */
   10.29 -	int attribs[64];
   10.30 -	int i;
   10.31 +   int i = 0;
   10.32 +	struct TagItem attributes [ 14 ]; /* 14 should be more than enough :) */
   10.33 +   struct Window *win = (struct Window *)SDL_Window;
   10.34  
   10.35 -	/* load the gl driver from a default path */
   10.36 -	if ( ! this->gl_config.driver_loaded ) {
   10.37 -	        /* no driver has been loaded, use default (ourselves) */
   10.38 -	        if ( X11_GL_LoadLibrary(this, NULL) < 0 ) {
   10.39 -		        return NULL;
   10.40 -		}
   10.41 +	// default config. Always used...
   10.42 +	attributes[i].ti_Tag = AMA_Window;	attributes[i++].ti_Data = (unsigned long)win;
   10.43 +	attributes[i].ti_Tag = AMA_Left;		attributes[i++].ti_Data = 0;
   10.44 +	attributes[i].ti_Tag = AMA_Bottom;	attributes[i++].ti_Data = 0;
   10.45 +	attributes[i].ti_Tag = AMA_Width;	attributes[i++].ti_Data = win->Width-win->BorderLeft-win->BorderRight;
   10.46 +	attributes[i].ti_Tag = AMA_Height;	attributes[i++].ti_Data = win->Height-win->BorderBottom-win->BorderTop;
   10.47 +	attributes[i].ti_Tag = AMA_DirectRender; attributes[i++].ti_Data = GL_TRUE;
   10.48 +
   10.49 +	// double buffer ?
   10.50 +	attributes[i].ti_Tag = AMA_DoubleBuf;
   10.51 +	if ( this->gl_config.double_buffer ) {
   10.52 +		attributes[i++].ti_Data = GL_TRUE;
   10.53  	}
   10.54 +	else {
   10.55 +		attributes[i++].ti_Data = GL_FALSE;
   10.56 +	}
   10.57 +	// RGB(A) Mode ?
   10.58 +	attributes[i].ti_Tag = AMA_RGBMode;
   10.59 +	if ( this->gl_config.red_size   != 0 &&
   10.60 +	     this->gl_config.blue_size  != 0 &&
   10.61 +	     this->gl_config.green_size != 0 ) {
   10.62 +		attributes[i++].ti_Data = GL_TRUE;
   10.63 +	}
   10.64 +	else {
   10.65 +		attributes[i++].ti_Data = GL_FALSE;
   10.66 +	}
   10.67 +	// no depth buffer ?
   10.68 +	if ( this->gl_config.depth_size == 0 ) {
   10.69 +		attributes[i].ti_Tag = AMA_NoDepth;
   10.70 +		attributes[i++].ti_Data = GL_TRUE;
   10.71 +	}
   10.72 +	// no stencil buffer ?
   10.73 +	if ( this->gl_config.stencil_size == 0 ) {
   10.74 +		attributes[i].ti_Tag = AMA_NoStencil;
   10.75 +		attributes[i++].ti_Data = GL_TRUE;
   10.76 +	}
   10.77 +	// no accum buffer ?
   10.78 +	if ( this->gl_config.accum_red_size   != 0 &&
   10.79 +	     this->gl_config.accum_blue_size  != 0 &&
   10.80 +	     this->gl_config.accum_green_size != 0 ) {
   10.81 +		attributes[i].ti_Tag = AMA_NoAccum;
   10.82 +		attributes[i++].ti_Data = GL_TRUE;
   10.83 +	}
   10.84 +	// done...
   10.85 +	attributes[i].ti_Tag	= TAG_DONE;
   10.86  
   10.87 -	/* See if we already have a window which we must use */
   10.88 -	if ( SDL_windowid ) {
   10.89 -		XWindowAttributes a;
   10.90 -		XVisualInfo vi_in;
   10.91 -		int out_count;
   10.92 +	glcont = AmigaMesaCreateContext(attributes);
   10.93 +	if ( glcont == NULL ) {
   10.94 +		SDL_SetError("Couldn't create OpenGL context");
   10.95 +		return(-1);
   10.96 +	}
   10.97 +	this->gl_data->gl_active = 1;
   10.98 +	this->gl_config.driver_loaded = 1;
   10.99  
  10.100 -		XGetWindowAttributes(SDL_Display, SDL_Window, &a);
  10.101 -		vi_in.screen = SDL_Screen;
  10.102 -		vi_in.visualid = XVisualIDFromVisual(a.visual);
  10.103 -		glx_visualinfo = XGetVisualInfo(SDL_Display,
  10.104 -	                     VisualScreenMask|VisualIDMask, &vi_in, &out_count);
  10.105 -		return glx_visualinfo;
  10.106 -	}
  10.107 -
  10.108 -        /* Setup our GLX attributes according to the gl_config. */
  10.109 -        i = 0;
  10.110 -        attribs[i++] = GLX_RGBA;
  10.111 -	attribs[i++] = GLX_RED_SIZE;
  10.112 -	attribs[i++] = this->gl_config.red_size;
  10.113 -	attribs[i++] = GLX_GREEN_SIZE;
  10.114 -	attribs[i++] = this->gl_config.green_size;
  10.115 -	attribs[i++] = GLX_BLUE_SIZE;
  10.116 -	attribs[i++] = this->gl_config.blue_size;
  10.117 -
  10.118 -	if( this->gl_config.alpha_size ) {
  10.119 -		attribs[i++] = GLX_ALPHA_SIZE;
  10.120 -		attribs[i++] = this->gl_config.alpha_size;
  10.121 -	}
  10.122 -
  10.123 -	if( this->gl_config.buffer_size ) {
  10.124 -                attribs[i++] = GLX_BUFFER_SIZE;
  10.125 -	        attribs[i++] = this->gl_config.buffer_size;
  10.126 -	}
  10.127 -
  10.128 -	if( this->gl_config.double_buffer ) {
  10.129 -		attribs[i++] = GLX_DOUBLEBUFFER;
  10.130 -	}
  10.131 -
  10.132 -	attribs[i++] = GLX_DEPTH_SIZE;
  10.133 -	attribs[i++] = this->gl_config.depth_size;
  10.134 -
  10.135 -	if( this->gl_config.stencil_size ) {
  10.136 -		attribs[i++] = GLX_STENCIL_SIZE;
  10.137 -		attribs[i++] = this->gl_config.stencil_size;
  10.138 -	}
  10.139 -
  10.140 -	if( this->gl_config.accum_red_size ) {
  10.141 -	        attribs[i++] = GLX_ACCUM_RED_SIZE;
  10.142 -		attribs[i++] = this->gl_config.accum_red_size;
  10.143 -	}
  10.144 -
  10.145 -	if( this->gl_config.accum_green_size ) {
  10.146 -	        attribs[i++] = GLX_ACCUM_GREEN_SIZE;
  10.147 -		attribs[i++] = this->gl_config.accum_green_size;
  10.148 -	}
  10.149 -
  10.150 -	if( this->gl_config.accum_blue_size ) {
  10.151 -	        attribs[i++] = GLX_ACCUM_BLUE_SIZE;
  10.152 -		attribs[i++] = this->gl_config.accum_blue_size;
  10.153 -	}
  10.154 -
  10.155 -	if( this->gl_config.accum_alpha_size ) {
  10.156 -	        attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
  10.157 -		attribs[i++] = this->gl_config.accum_alpha_size;
  10.158 -	}
  10.159 -
  10.160 -	attribs[i++] = None;
  10.161 -
  10.162 - 	glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, 
  10.163 -						  SDL_Screen, attribs);
  10.164 -	if( !glx_visualinfo ) {
  10.165 -		SDL_SetError( "Couldn't find matching GLX visual");
  10.166 -		return NULL;
  10.167 -	}
  10.168 -	return glx_visualinfo;
  10.169 +	return(0);
  10.170  #else
  10.171 -	SDL_SetError("CGX driver is not yet supporting OpenGL");
  10.172 -	return NULL;
  10.173 +	SDL_SetError("OpenGL support not configured");
  10.174 +	return(-1);
  10.175  #endif
  10.176  }
  10.177  
  10.178 -int CGX_GL_CreateWindow(_THIS, int w, int h)
  10.179 +/* Quit OpenGL */
  10.180 +void CGX_GL_Quit(_THIS)
  10.181  {
  10.182 -	int retval;
  10.183  #ifdef HAVE_OPENGL
  10.184 -	XSetWindowAttributes attributes;
  10.185 -	unsigned long mask;
  10.186 -	unsigned long black;
  10.187 -
  10.188 -	black = (glx_visualinfo->visual == DefaultVisual(SDL_Display,
  10.189 -						 	SDL_Screen))
  10.190 -	       	? BlackPixel(SDL_Display, SDL_Screen) : 0;
  10.191 -	attributes.background_pixel = black;
  10.192 -	attributes.border_pixel = black;
  10.193 -	attributes.colormap = SDL_XColorMap;
  10.194 -	mask = CWBackPixel | CWBorderPixel | CWColormap;
  10.195 -
  10.196 -	SDL_Window = XCreateWindow(SDL_Display, WMwindow,
  10.197 -			0, 0, w, h, 0, glx_visualinfo->depth,
  10.198 -			InputOutput, glx_visualinfo->visual,
  10.199 -			mask, &attributes);
  10.200 -	if ( !SDL_Window ) {
  10.201 -		SDL_SetError("Could not create window");
  10.202 -		return -1;
  10.203 +	if ( glcont != NULL ) {
  10.204 +		AmigaMesaDestroyContext(glcont);
  10.205 +		glcont = NULL;
  10.206 +		this->gl_data->gl_active = 0;
  10.207 +		this->gl_config.driver_loaded = 0;
  10.208  	}
  10.209 -	retval = 0;
  10.210 -#else
  10.211 -	SDL_SetError("CGX driver is not yet supporting OpenGL");
  10.212 -	retval = -1;
  10.213  #endif
  10.214 -	return(retval);
  10.215  }
  10.216  
  10.217 -int CGX_GL_CreateContext(_THIS)
  10.218 -{
  10.219 -	int retval;
  10.220 -#ifdef HAVE_OPENGL
  10.221 -	/* We do this to create a clean separation between X and GLX errors. */
  10.222 -	XSync( SDL_Display, False );
  10.223 -	glx_context = this->gl_data->glXCreateContext(GFX_Display, 
  10.224 -				     glx_visualinfo, NULL, True);
  10.225 -	XSync( GFX_Display, False );
  10.226 -
  10.227 -	if (glx_context == NULL) {
  10.228 -		SDL_SetError("Could not create GL context");
  10.229 -		return -1;
  10.230 -	}
  10.231 -
  10.232 -	gl_active = 1;
  10.233 -#else
  10.234 -	SDL_SetError("CGX driver is not yet supporting OpenGL");
  10.235 -#endif
  10.236 -	if ( gl_active ) {
  10.237 -		retval = 0;
  10.238 -	} else {
  10.239 -		retval = -1;
  10.240 -	}
  10.241 -	return(retval);
  10.242 -}
  10.243 -
  10.244 -void CGX_GL_Shutdown(_THIS)
  10.245 +/* Attach context to another window */
  10.246 +int CGX_GL_Update(_THIS)
  10.247  {
  10.248  #ifdef HAVE_OPENGL
  10.249 -	/* Clean up OpenGL */
  10.250 -	if( glx_context ) {
  10.251 -		this->gl_data->glXMakeCurrent(GFX_Display, None, NULL);
  10.252 +	struct TagItem tags[2];
  10.253 +	struct Window *win = (struct Window*)SDL_Window;
  10.254 +	if(glcont == NULL) {
  10.255 +		return -1; //should never happen
  10.256 +	}
  10.257 +	tags[0].ti_Tag = AMA_Window;
  10.258 +	tags[0].ti_Data = (unsigned long)win;
  10.259 +	tags[1].ti_Tag = TAG_DONE;
  10.260 +	AmigaMesaSetRast(glcont, tags);
  10.261  
  10.262 -		if (glx_context != NULL)
  10.263 -			this->gl_data->glXDestroyContext(GFX_Display, glx_context);
  10.264 -
  10.265 -		if( this->gl_data->glXReleaseBuffersMESA ) {
  10.266 -		    this->gl_data->glXReleaseBuffersMESA(GFX_Display,SDL_Window);
  10.267 -		}
  10.268 -		glx_context = NULL;
  10.269 -	}
  10.270 -	gl_active = 0;
  10.271 -#endif /* HAVE_OPENGL */
  10.272 +	return 0;
  10.273 +#else
  10.274 +	SDL_SetError("OpenGL support not configured");
  10.275 +	return -1;
  10.276 +#endif
  10.277  }
  10.278  
  10.279  #ifdef HAVE_OPENGL
  10.280 @@ -215,175 +143,75 @@
  10.281  /* Make the current context active */
  10.282  int CGX_GL_MakeCurrent(_THIS)
  10.283  {
  10.284 -	int retval;
  10.285 +	if(glcont == NULL)
  10.286 +		return -1;
  10.287  
  10.288 -	retval = 0;
  10.289 -	if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
  10.290 -	                                     SDL_Window, glx_context) ) {
  10.291 -		SDL_SetError("Unable to make GL context current");
  10.292 -		retval = -1;
  10.293 -	}
  10.294 -	XSync( GFX_Display, False );
  10.295 -
  10.296 -	/* More Voodoo X server workarounds... Grr... */
  10.297 -	SDL_Lock_EventThread();
  10.298 -	X11_CheckDGAMouse(this);
  10.299 -	SDL_Unlock_EventThread();
  10.300 -
  10.301 -	return(retval);
  10.302 -}
  10.303 -
  10.304 -/* Get attribute data from glX. */
  10.305 -int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
  10.306 -{
  10.307 -	int retval;
  10.308 -	int glx_attrib = None;
  10.309 -
  10.310 -	switch( attrib ) {
  10.311 -	    case SDL_GL_RED_SIZE:
  10.312 -		glx_attrib = GLX_RED_SIZE;
  10.313 -		break;
  10.314 -	    case SDL_GL_GREEN_SIZE:
  10.315 -		glx_attrib = GLX_GREEN_SIZE;
  10.316 -		break;
  10.317 -	    case SDL_GL_BLUE_SIZE:
  10.318 -		glx_attrib = GLX_BLUE_SIZE;
  10.319 -		break;
  10.320 -	    case SDL_GL_ALPHA_SIZE:
  10.321 -		glx_attrib = GLX_ALPHA_SIZE;
  10.322 -		break;
  10.323 -	    case SDL_GL_DOUBLEBUFFER:
  10.324 -		glx_attrib = GLX_DOUBLEBUFFER;
  10.325 -		break;
  10.326 -	    case SDL_GL_BUFFER_SIZE:
  10.327 -		glx_attrib = GLX_BUFFER_SIZE;
  10.328 -		break;
  10.329 -	    case SDL_GL_DEPTH_SIZE:
  10.330 -		glx_attrib = GLX_DEPTH_SIZE;
  10.331 -		break;
  10.332 -	    case SDL_GL_STENCIL_SIZE:
  10.333 -		glx_attrib = GLX_STENCIL_SIZE;
  10.334 -		break;
  10.335 -	    case SDL_GL_ACCUM_RED_SIZE:
  10.336 -		glx_attrib = GLX_ACCUM_RED_SIZE;
  10.337 -		break;
  10.338 -	    case SDL_GL_ACCUM_GREEN_SIZE:
  10.339 -		glx_attrib = GLX_ACCUM_GREEN_SIZE;
  10.340 -		break;
  10.341 -	    case SDL_GL_ACCUM_BLUE_SIZE:
  10.342 -		glx_attrib = GLX_ACCUM_BLUE_SIZE;
  10.343 -		break;
  10.344 -	    case SDL_GL_ACCUM_ALPHA_SIZE:
  10.345 -		glx_attrib = GLX_ACCUM_ALPHA_SIZE;
  10.346 -		break;
  10.347 -	    default:
  10.348 -		return(-1);
  10.349 -	}
  10.350 -
  10.351 -	retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value);
  10.352 -
  10.353 -	return retval;
  10.354 +	AmigaMesaMakeCurrent(glcont, glcont->buffer);
  10.355 +	return 0;
  10.356  }
  10.357  
  10.358  void CGX_GL_SwapBuffers(_THIS)
  10.359  {
  10.360 -	this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window);
  10.361 +	AmigaMesaSwapBuffers(glcont);
  10.362 +}
  10.363 +
  10.364 +int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) {
  10.365 +	GLenum mesa_attrib;
  10.366 +
  10.367 +	switch(attrib) {
  10.368 +		case SDL_GL_RED_SIZE:
  10.369 +			mesa_attrib = GL_RED_BITS;
  10.370 +			break;
  10.371 +		case SDL_GL_GREEN_SIZE:
  10.372 +			mesa_attrib = GL_GREEN_BITS;
  10.373 +			break;
  10.374 +		case SDL_GL_BLUE_SIZE:
  10.375 +			mesa_attrib = GL_BLUE_BITS;
  10.376 +			break;
  10.377 +		case SDL_GL_ALPHA_SIZE:
  10.378 +			mesa_attrib = GL_ALPHA_BITS;
  10.379 +			break;
  10.380 +		case SDL_GL_DOUBLEBUFFER:
  10.381 +			mesa_attrib = GL_DOUBLEBUFFER;
  10.382 +			break;
  10.383 +		case SDL_GL_DEPTH_SIZE:
  10.384 +			mesa_attrib = GL_DEPTH_BITS;
  10.385 +			break;
  10.386 +		case SDL_GL_STENCIL_SIZE:
  10.387 +			mesa_attrib = GL_STENCIL_BITS;
  10.388 +			break;
  10.389 +		case SDL_GL_ACCUM_RED_SIZE:
  10.390 +			mesa_attrib = GL_ACCUM_RED_BITS;
  10.391 +			break;
  10.392 +		case SDL_GL_ACCUM_GREEN_SIZE:
  10.393 +			mesa_attrib = GL_ACCUM_GREEN_BITS;
  10.394 +			break;
  10.395 +		case SDL_GL_ACCUM_BLUE_SIZE:
  10.396 +			mesa_attrib = GL_ACCUM_BLUE_BITS;
  10.397 +			break;
  10.398 +		case SDL_GL_ACCUM_ALPHA_SIZE:
  10.399 +			mesa_attrib = GL_ACCUM_ALPHA_BITS;
  10.400 +			break;
  10.401 +		default :
  10.402 +			return -1;
  10.403 +	}
  10.404 +
  10.405 +	AmigaMesaGetConfig(glcont->visual, mesa_attrib, value);
  10.406 +	return 0;
  10.407 +}
  10.408 +
  10.409 +void *CGX_GL_GetProcAddress(_THIS, const char *proc) {
  10.410 +	void *func = NULL;
  10.411 +	func = AmiGetGLProc(proc);
  10.412 +	return func;
  10.413 +}
  10.414 +
  10.415 +int CGX_GL_LoadLibrary(_THIS, const char *path) {
  10.416 +	/* Library is always open */
  10.417 +	this->gl_config.driver_loaded = 1;
  10.418 +
  10.419 +	return 0;
  10.420  }
  10.421  
  10.422  #endif /* HAVE_OPENGL */
  10.423  
  10.424 -void CGX_GL_UnloadLibrary(_THIS)
  10.425 -{
  10.426 -#ifdef HAVE_OPENGL
  10.427 -	if ( this->gl_config.driver_loaded ) {
  10.428 -		dlclose(this->gl_config.dll_handle);
  10.429 -
  10.430 -		this->gl_data->glXChooseVisual = NULL;
  10.431 -		this->gl_data->glXCreateContext = NULL;
  10.432 -		this->gl_data->glXDestroyContext = NULL;
  10.433 -		this->gl_data->glXMakeCurrent = NULL;
  10.434 -		this->gl_data->glXSwapBuffers = NULL;
  10.435 -
  10.436 -		this->gl_config.dll_handle = NULL;
  10.437 -		this->gl_config.driver_loaded = 0;
  10.438 -	}
  10.439 -#endif
  10.440 -}
  10.441 -
  10.442 -#ifdef HAVE_OPENGL
  10.443 -
  10.444 -/* Passing a NULL path means load pointers from the application */
  10.445 -int CGX_GL_LoadLibrary(_THIS, const char* path) 
  10.446 -{
  10.447 -	void* handle;
  10.448 -	int dlopen_flags;
  10.449 -
  10.450 - 	if ( gl_active ) {
  10.451 - 		SDL_SetError("OpenGL context already created");
  10.452 - 		return -1;
  10.453 - 	}
  10.454 -
  10.455 -#ifdef RTLD_GLOBAL
  10.456 -	dlopen_flags = RTLD_LAZY | RTLD_GLOBAL;
  10.457 -#else
  10.458 -	dlopen_flags = RTLD_LAZY;
  10.459 -#endif
  10.460 -	handle = dlopen(path, dlopen_flags);
  10.461 -	/* Catch the case where the application isn't linked with GL */
  10.462 -	if ( (dlsym(handle, "glXChooseVisual") == NULL) && (path == NULL) ) {
  10.463 -		dlclose(handle);
  10.464 -		path = getenv("SDL_VIDEO_GL_DRIVER");
  10.465 -		if ( path == NULL ) {
  10.466 -			path = DEFAULT_OPENGL;
  10.467 -		}
  10.468 -		handle = dlopen(path, dlopen_flags);
  10.469 -	}
  10.470 -	if ( handle == NULL ) {
  10.471 -		SDL_SetError("Could not load OpenGL library");
  10.472 -		return -1;
  10.473 -	}
  10.474 -
  10.475 -	/* Unload the old driver and reset the pointers */
  10.476 -	X11_GL_UnloadLibrary(this);
  10.477 -
  10.478 -	/* Load new function pointers */
  10.479 -	this->gl_data->glXChooseVisual = dlsym(handle, "glXChooseVisual");
  10.480 -	this->gl_data->glXCreateContext = dlsym(handle, "glXCreateContext");
  10.481 -	this->gl_data->glXDestroyContext = dlsym(handle, "glXDestroyContext");
  10.482 -	this->gl_data->glXMakeCurrent = dlsym(handle, "glXMakeCurrent");
  10.483 -	this->gl_data->glXSwapBuffers = dlsym(handle, "glXSwapBuffers");
  10.484 -	this->gl_data->glXGetConfig = dlsym(handle, "glXGetConfig");
  10.485 -	/* We don't compare below for this in case we're not using Mesa. */
  10.486 -	this->gl_data->glXReleaseBuffersMESA = dlsym( handle, "glXReleaseBuffersMESA" );
  10.487 -
  10.488 -	if ( (this->gl_data->glXChooseVisual == NULL) || 
  10.489 -	     (this->gl_data->glXCreateContext == NULL) ||
  10.490 -	     (this->gl_data->glXDestroyContext == NULL) ||
  10.491 -	     (this->gl_data->glXMakeCurrent == NULL) ||
  10.492 -	     (this->gl_data->glXSwapBuffers == NULL) ||
  10.493 -	     (this->gl_data->glXGetConfig == NULL) ) {
  10.494 -		SDL_SetError("Could not retrieve OpenGL functions");
  10.495 -		return -1;
  10.496 -	}
  10.497 -
  10.498 -	this->gl_config.dll_handle = handle;
  10.499 -	this->gl_config.driver_loaded = 1;
  10.500 -	if ( path ) {
  10.501 -		strncpy(this->gl_config.driver_path, path,
  10.502 -			sizeof(this->gl_config.driver_path)-1);
  10.503 -	} else {
  10.504 -		strcpy(this->gl_config.driver_path, "");
  10.505 -	}
  10.506 -	return 0;
  10.507 -}
  10.508 -
  10.509 -void *CGX_GL_GetProcAddress(_THIS, const char* proc)
  10.510 -{
  10.511 -	void* handle;
  10.512 -	
  10.513 -	handle = this->gl_config.dll_handle;
  10.514 -
  10.515 -	return dlsym(handle, proc);
  10.516 -}
  10.517 -
  10.518 -#endif /* HAVE_OPENGL */
    11.1 --- a/src/video/cybergfx/SDL_cgxgl_c.h	Fri Dec 14 13:13:20 2001 +0000
    11.2 +++ b/src/video/cybergfx/SDL_cgxgl_c.h	Sun Dec 16 20:00:27 2001 +0000
    11.3 @@ -25,74 +25,30 @@
    11.4   "@(#) $Id$";
    11.5  #endif
    11.6  
    11.7 -#include <stdio.h>
    11.8 +/* StormMesa implementation of SDL OpenGL support */
    11.9 +
   11.10 +#include "SDL_sysvideo.h"
   11.11 +#define _THIS   SDL_VideoDevice *_this
   11.12  
   11.13  #ifdef HAVE_OPENGL
   11.14 -#include <GL/glx.h>
   11.15 -#include <dlfcn.h>
   11.16 -#endif
   11.17 -#include "SDL_sysvideo.h"
   11.18 +#include <GL/Amigamesa.h>
   11.19 +extern void *AmiGetGLProc(const char *proc);
   11.20 +#endif /* HAVE_OPENGL */
   11.21  
   11.22  struct SDL_PrivateGLData {
   11.23 -    int gl_active; /* to stop switching drivers while we have a valid context */
   11.24 -
   11.25 -#ifdef HAVE_OPENGL
   11.26 -    GLXContext glx_context;	/* Current GL context */
   11.27 -    XVisualInfo* glx_visualinfo; /* XVisualInfo* returned by glXChooseVisual */
   11.28 -
   11.29 -    XVisualInfo* (*glXChooseVisual)
   11.30 -		( Display*		dpy,
   11.31 -		  int			screen,
   11.32 -		  int*		attribList );
   11.33 -
   11.34 -    GLXContext (*glXCreateContext)
   11.35 -		( Display*		dpy,
   11.36 -		  XVisualInfo*	vis,
   11.37 -		  GLXContext		shareList,
   11.38 -		  Bool		direct );
   11.39 -
   11.40 -    void (*glXDestroyContext)
   11.41 -		( Display* 		dpy,
   11.42 -		  GLXContext		ctx );
   11.43 -
   11.44 -    Bool (*glXMakeCurrent)
   11.45 -		( Display*		dpy,
   11.46 -		  GLXDrawable		drawable,
   11.47 -		  GLXContext		ctx );
   11.48 -
   11.49 -    void (*glXSwapBuffers)
   11.50 -		( Display*		dpy,
   11.51 -		  GLXDrawable		drawable );
   11.52 -
   11.53 -    int (*glXGetConfig)
   11.54 -	 ( Display* dpy,
   11.55 -	   XVisualInfo* visual_info,
   11.56 -	   int attrib,
   11.57 -	   int* value );
   11.58 -
   11.59 -    void (*glXReleaseBuffersMESA)
   11.60 -	 ( Display* dpy,
   11.61 -	   GLXDrawable drawable );
   11.62 -
   11.63 -#endif /* HAVE_OPENGL */
   11.64 +	int gl_active;
   11.65  };
   11.66  
   11.67 -/* Old variable names */
   11.68 -#define gl_active		(this->gl_data->gl_active)
   11.69 -#define glx_context		(this->gl_data->glx_context)
   11.70 -#define glx_visualinfo		(this->gl_data->glx_visualinfo)
   11.71 -
   11.72  /* OpenGL functions */
   11.73 -extern void *CGX_GL_GetVisual(_THIS);
   11.74 -extern int CGX_GL_CreateWindow(_THIS, int w, int h);
   11.75 -extern int CGX_GL_CreateContext(_THIS);
   11.76 -extern void CGX_GL_Shutdown(_THIS);
   11.77 +extern int CGX_GL_Init(_THIS);
   11.78 +extern void CGX_GL_Quit(_THIS);
   11.79 +extern int CGX_GL_Update(_THIS);
   11.80  #ifdef HAVE_OPENGL
   11.81  extern int CGX_GL_MakeCurrent(_THIS);
   11.82  extern int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
   11.83  extern void CGX_GL_SwapBuffers(_THIS);
   11.84 -extern int CGX_GL_LoadLibrary(_THIS, const char* path);
   11.85 -extern void *CGX_GL_GetProcAddress(_THIS, const char* proc);
   11.86 +extern void *CGX_GL_GetProcAddress(_THIS, const char *proc);
   11.87 +extern int CGX_GL_LoadLibrary(_THIS, const char *path);
   11.88  #endif
   11.89 -extern void CGX_GL_UnloadLibrary(_THIS);
   11.90  
   11.91 +#undef _THIS
    12.1 --- a/src/video/cybergfx/SDL_cgximage.c	Fri Dec 14 13:13:20 2001 +0000
    12.2 +++ b/src/video/cybergfx/SDL_cgximage.c	Sun Dec 16 20:00:27 2001 +0000
    12.3 @@ -52,36 +52,35 @@
    12.4  BOOL SafeDisp=TRUE,SafeChange=TRUE;
    12.5  struct MsgPort *safeport=NULL,*dispport=NULL;
    12.6  ULONG safe_sigbit,disp_sigbit;
    12.7 +int use_picasso96=1;
    12.8  
    12.9  int CGX_SetupImage(_THIS, SDL_Surface *screen)
   12.10  {
   12.11 -	if(screen->flags&SDL_HWSURFACE)
   12.12 -	{
   12.13 -		Uint32 pitch;
   12.14 -		SDL_Ximage=NULL;
   12.15 +	SDL_Ximage=NULL;
   12.16  
   12.17 -		if(!screen->hwdata)
   12.18 -		{
   12.19 +	if(screen->flags&SDL_HWSURFACE) {
   12.20 +		ULONG pitch;
   12.21 +
   12.22 +		if(!screen->hwdata) {
   12.23  			if(!(screen->hwdata=malloc(sizeof(struct private_hwdata))))
   12.24 -			{
   12.25  				return -1;
   12.26 -			}
   12.27 +
   12.28  			D(bug("Creating system accel struct\n"));
   12.29  		}
   12.30 -		screen->hwdata->lock=0;
   12.31 +		screen->hwdata->lock=NULL;
   12.32 +		screen->hwdata->allocated=0;
   12.33 +		screen->hwdata->mask=NULL;
   12.34  		screen->hwdata->bmap=SDL_RastPort->BitMap;
   12.35  		screen->hwdata->videodata=this;
   12.36  
   12.37  		if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap,
   12.38  				LBMI_BASEADDRESS,(ULONG)&screen->pixels,
   12.39 -				LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE)))
   12.40 -		{
   12.41 +				LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) {
   12.42  			free(screen->hwdata);
   12.43  			screen->hwdata=NULL;
   12.44  			return -1;
   12.45  		}
   12.46 -		else
   12.47 -		{
   12.48 +		else {
   12.49  			UnLockBitMap(screen->hwdata->lock);
   12.50  			screen->hwdata->lock=NULL;
   12.51  		}
   12.52 @@ -101,17 +100,6 @@
   12.53  		return(-1);
   12.54  	}
   12.55  
   12.56 -/*
   12.57 -	{
   12.58 - 	        int bpp = screen->format->BytesPerPixel;
   12.59 -			SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
   12.60 -					  this->hidden->depth, ZPixmap, 0,
   12.61 -					  (char *)screen->pixels, 
   12.62 -					  screen->w, screen->h,
   12.63 -					  (bpp == 3) ? 32 : bpp * 8,
   12.64 -					  0);
   12.65 -	}
   12.66 -*/
   12.67  	SDL_Ximage=screen->pixels;
   12.68  
   12.69  	if ( SDL_Ximage == NULL ) {
   12.70 @@ -132,6 +120,11 @@
   12.71  	}
   12.72  	if ( screen ) {
   12.73  		screen->pixels = NULL;
   12.74 +
   12.75 +		if(screen->hwdata) {
   12.76 +			free(screen->hwdata);
   12.77 +			screen->hwdata=NULL;
   12.78 +		}
   12.79  	}
   12.80  }
   12.81  
   12.82 @@ -145,21 +138,16 @@
   12.83  {
   12.84  	int retval;
   12.85  
   12.86 -	D(bug("Chiamata ResizeImage!\n"));
   12.87 +	D(bug("Calling ResizeImage()\n"));
   12.88  
   12.89  	CGX_DestroyImage(this, screen);
   12.90  
   12.91 -    if ( flags & SDL_OPENGL ) {  /* No image when using GL */
   12.92 +	if ( flags & SDL_OPENGL ) {  /* No image when using GL */
   12.93          	retval = 0;
   12.94 -    } else {
   12.95 +	} else {
   12.96  		retval = CGX_SetupImage(this, screen);
   12.97  		/* We support asynchronous blitting on the display */
   12.98  		if ( flags & SDL_ASYNCBLIT ) {
   12.99 -			/* This is actually slower on single-CPU systems,
  12.100 -			   probably because of CPU contention between the
  12.101 -			   X server and the application.
  12.102 -			   Note: Is this still true with XFree86 4.0?
  12.103 -			*/
  12.104  			if ( num_CPU() > 1 ) {
  12.105  				screen->flags |= SDL_ASYNCBLIT;
  12.106  			}
  12.107 @@ -168,7 +156,6 @@
  12.108  	return(retval);
  12.109  }
  12.110  
  12.111 -/* We don't actually allow hardware surfaces other than the main one */
  12.112  int CGX_AllocHWSurface(_THIS, SDL_Surface *surface)
  12.113  {
  12.114  	D(bug("Alloc HW surface...%ld x %ld x %ld!\n",surface->w,surface->h,this->hidden->depth));
  12.115 @@ -185,11 +172,14 @@
  12.116  			return -1;
  12.117  	}
  12.118  
  12.119 +	surface->hwdata->mask=NULL;
  12.120  	surface->hwdata->lock=NULL;
  12.121  	surface->hwdata->videodata=this;
  12.122 +	surface->hwdata->allocated=0;
  12.123  
  12.124  	if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap))
  12.125  	{
  12.126 +		surface->hwdata->allocated=1;
  12.127  		surface->flags|=SDL_HWSURFACE;
  12.128  		D(bug("...OK\n"));
  12.129  		return 0;
  12.130 @@ -211,11 +201,13 @@
  12.131  		if(surface->hwdata->mask)
  12.132  			free(surface->hwdata->mask);
  12.133  
  12.134 -		if(surface->hwdata->bmap)
  12.135 +		if(surface->hwdata->bmap&&surface->hwdata->allocated)
  12.136  			FreeBitMap(surface->hwdata->bmap);
  12.137  
  12.138  		free(surface->hwdata);
  12.139  		surface->hwdata=NULL;
  12.140 +		surface->pixels=NULL;
  12.141 +		D(bug("end of free hw surface\n"));
  12.142  	}
  12.143  	return;
  12.144  }
  12.145 @@ -242,11 +234,11 @@
  12.146  				surface->pixels=((char *)surface->pixels)+(surface->pitch*(SDL_Window->BorderTop+SDL_Window->TopEdge)+
  12.147  					surface->format->BytesPerPixel*(SDL_Window->BorderLeft+SDL_Window->LeftEdge));
  12.148  		}
  12.149 -		else
  12.150 -			D(bug("Already locked!!!\n"));
  12.151 +		D(else bug("Already locked!!!\n"));
  12.152  	}
  12.153  	return(0);
  12.154  }
  12.155 +
  12.156  void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface)
  12.157  {
  12.158  	if(surface->hwdata && surface->hwdata->lock)
  12.159 @@ -398,7 +390,7 @@
  12.160  #ifndef USE_CGX_WRITELUTPIXEL
  12.161  	int bpp;
  12.162  #endif
  12.163 -	if(this->hidden->same_format)
  12.164 +	if(this->hidden->same_format && !use_picasso96)
  12.165  	{
  12.166  		format=RECTFMT_RAW;
  12.167  	}
  12.168 @@ -445,7 +437,7 @@
  12.169  	/* Check for endian-swapped X server, swap if necessary (VERY slow!) */
  12.170  	if ( swap_pixels &&
  12.171  	     ((this->screen->format->BytesPerPixel%2) == 0) ) {
  12.172 -		D(bug("Swappo! Lento!\n"));
  12.173 +		D(bug("Software Swapping! SLOOOW!\n"));
  12.174  		CGX_SwapPixels(this->screen, numrects, rects);
  12.175  		for ( i=0; i<numrects; ++i ) {
  12.176  			if ( ! rects[i].w ) { /* Clipped? */
  12.177 @@ -633,7 +625,7 @@
  12.178  		Uint32	destpitch;
  12.179  		APTR handle;
  12.180  
  12.181 -//		D(bug("Uso customroutine!\n"));
  12.182 +//		D(bug("Using customroutine!\n"));
  12.183  
  12.184  		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
  12.185  								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
  12.186 @@ -685,20 +677,8 @@
  12.187  			USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch,
  12.188  					SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y,
  12.189  					rects[i].w,rects[i].h,format);
  12.190 -
  12.191 -/*
  12.192 -			XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
  12.193 -				rects[i].x, rects[i].y,
  12.194 -				rects[i].x, rects[i].y, rects[i].w, rects[i].h);
  12.195 -*/
  12.196  		}
  12.197  	}
  12.198 -/*
  12.199 -	if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
  12.200 -		++blit_queued;
  12.201 -	} else {
  12.202 -	}
  12.203 -*/
  12.204  }
  12.205  
  12.206  void CGX_RefreshDisplay(_THIS)
  12.207 @@ -712,7 +692,7 @@
  12.208  		return;
  12.209  	}
  12.210  
  12.211 -	if(this->hidden->same_format)
  12.212 +	if(this->hidden->same_format && !use_picasso96)
  12.213  	{
  12.214  		format=RECTFMT_RAW;
  12.215  	}
    13.1 --- a/src/video/cybergfx/SDL_cgxmodes.c	Fri Dec 14 13:13:20 2001 +0000
    13.2 +++ b/src/video/cybergfx/SDL_cgxmodes.c	Sun Dec 16 20:00:27 2001 +0000
    13.3 @@ -1,6 +1,6 @@
    13.4  /*
    13.5      SDL - Simple DirectMedia Layer
    13.6 -    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    13.7 +    Copyright (C) 1997, 1998, 1999, 2000  Sam Lantinga
    13.8  
    13.9      This library is free software; you can redistribute it and/or
   13.10      modify it under the terms of the GNU Library General Public
   13.11 @@ -66,14 +66,15 @@
   13.12  		}
   13.13  		SDL_Display=GFX_Display=OpenScreenTags(NULL,SA_Width,width,SA_Height,height,
   13.14  											SA_Depth,depth,SA_DisplayID,idok,
   13.15 +											SA_ShowTitle,FALSE,
   13.16  											TAG_DONE);
   13.17  	}
   13.18  }
   13.19  
   13.20  static void get_real_resolution(_THIS, int* w, int* h)
   13.21  {
   13.22 -    *w = SDL_Display->Width;
   13.23 -    *h = SDL_Display->Height;
   13.24 +    *w = /*SDL_Display->Width*/ SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight;
   13.25 +    *h = /*SDL_Display->Height*/ SDL_Window->Height-SDL_Window->BorderBottom-SDL_Window->BorderTop;
   13.26  }
   13.27  
   13.28  static void move_cursor_to(_THIS, int x, int y)
   13.29 @@ -144,11 +145,11 @@
   13.30  						SDL_modelist = (SDL_Rect **)realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *));
   13.31  						SDL_modelist[nmodes]=NULL;
   13.32  
   13.33 -						if ( SDL_modelist ) 
   13.34 +						if ( SDL_modelist )
   13.35  						{
   13.36  							SDL_modelist[nmodes-1] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
   13.37  
   13.38 -							if ( SDL_modelist[nmodes-1] == NULL ) 
   13.39 +							if ( SDL_modelist[nmodes-1] == NULL )
   13.40  								break;
   13.41  
   13.42  							SDL_modelist[nmodes-1]->x = 0;
   13.43 @@ -156,7 +157,7 @@
   13.44  							SDL_modelist[nmodes-1]->w = info.Nominal.MaxX+1;
   13.45  							SDL_modelist[nmodes-1]->h = info.Nominal.MaxY+1;
   13.46  						}
   13.47 -					}																	
   13.48 +					}
   13.49  				}
   13.50  			}
   13.51  		}
   13.52 @@ -267,15 +268,18 @@
   13.53  int CGX_EnterFullScreen(_THIS)
   13.54  {
   13.55      int okay;
   13.56 +	 Uint32 saved_flags;
   13.57  
   13.58      okay = 1;
   13.59 -    if ( ! currently_fullscreen ) 
   13.60 +    saved_flags = this->screen->flags;
   13.61 +
   13.62 +    if ( ! currently_fullscreen )
   13.63  	{
   13.64          int real_w, real_h;
   13.65  
   13.66          /* Map the fullscreen window to blank the screen */
   13.67          get_real_resolution(this, &real_w, &real_h);
   13.68 -		
   13.69 +
   13.70  		CGX_DestroyWindow(this,this->screen);
   13.71  		set_best_resolution(this, real_w,real_h);
   13.72  
   13.73 @@ -297,8 +301,9 @@
   13.74  #endif
   13.75  
   13.76          currently_fullscreen = 1;
   13.77 +		  this->screen->flags = saved_flags;
   13.78  
   13.79 -		CGX_CreateWindow(this,this->screen,real_w,real_h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags);
   13.80 +		  CGX_CreateWindow(this,this->screen,real_w,real_h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags);
   13.81  
   13.82          /* Set the new resolution */
   13.83          okay = CGX_ResizeFullScreen(this);
   13.84 @@ -311,7 +316,7 @@
   13.85  			XInstallColormap(SDL_Display, SDL_XColorMap);
   13.86  		}
   13.87  */
   13.88 -    }    
   13.89 +    }
   13.90  //    CGX_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
   13.91      return(okay);
   13.92  }
    14.1 --- a/src/video/cybergfx/SDL_cgxvideo.c	Fri Dec 14 13:13:20 2001 +0000
    14.2 +++ b/src/video/cybergfx/SDL_cgxvideo.c	Sun Dec 16 20:00:27 2001 +0000
    14.3 @@ -1,6 +1,6 @@
    14.4  /*
    14.5      SDL - Simple DirectMedia Layer
    14.6 -    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    14.7 +    Copyright (C) 1997, 1998, 1999, 2000  Sam Lantinga
    14.8  
    14.9      This library is free software; you can redistribute it and/or
   14.10      modify it under the terms of the GNU Library General Public
   14.11 @@ -25,8 +25,10 @@
   14.12   "@(#) $Id$";
   14.13  #endif
   14.14  
   14.15 -/* CGX based SDL video driver implementation.
   14.16 -*/
   14.17 +/*
   14.18 + * CGX based SDL video driver implementation by Gabriele Greco
   14.19 + * gabriele.greco@aruba.it
   14.20 + */
   14.21  
   14.22  /*
   14.23  #include <stdlib.h>
   14.24 @@ -50,6 +52,7 @@
   14.25  #include "SDL_sysvideo.h"
   14.26  #include "SDL_pixels_c.h"
   14.27  #include "SDL_events_c.h"
   14.28 +#include "SDL_cgxgl_c.h"
   14.29  #include "SDL_cgxvideo.h"
   14.30  #include "SDL_cgxwm_c.h"
   14.31  #include "SDL_amigamouse_c.h"
   14.32 @@ -57,7 +60,6 @@
   14.33  #include "SDL_cgxmodes_c.h"
   14.34  #include "SDL_cgximage_c.h"
   14.35  #include "SDL_cgxyuv_c.h"
   14.36 -#include "SDL_cgxgl_c.h"
   14.37  
   14.38  /* Initialization/Query functions */
   14.39  static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat);
   14.40 @@ -73,6 +75,52 @@
   14.41  struct IntuitionBase *IntuitionBase=NULL;
   14.42  struct GfxBase *GfxBase=NULL;
   14.43  
   14.44 +int CGX_SetGamma(_THIS, float red, float green, float blue)
   14.45 +{
   14.46 +    SDL_SetError("Gamma correction not supported");
   14.47 +    return -1;
   14.48 +}
   14.49 +
   14.50 +int CGX_GetGamma(_THIS, float red, float green, float blue)
   14.51 +{
   14.52 +    SDL_SetError("Gamma correction not supported");
   14.53 +    return -1;
   14.54 +}
   14.55 +
   14.56 +int CGX_SetGammaRamp(_THIS, Uint16 *ramp)
   14.57 +{
   14.58 +#if 0
   14.59 +	Int i, ncolors;
   14.60 +	XColor xcmap[256];
   14.61 +
   14.62 +	/* See if actually setting the gamma is supported */
   14.63 +	if ( SDL_Visual->class != DirectColor ) {
   14.64 +	    SDL_SetError("Gamma correction not supported on this visual");
   14.65 +	    return(-1);
   14.66 +	}
   14.67 +
   14.68 +	/* Calculate the appropriate palette for the given gamma ramp */
   14.69 +	ncolors = SDL_Visual->map_entries;
   14.70 +	for ( i=0; i<ncolors; ++i ) {
   14.71 +		Uint8 c = (256 * i / ncolors);
   14.72 +		xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c);
   14.73 +		xcmap[i].red   = ramp[0*256+c];
   14.74 +		xcmap[i].green = ramp[1*256+c];
   14.75 +		xcmap[i].blue  = ramp[2*256+c];
   14.76 +		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
   14.77 +	}
   14.78 +	XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
   14.79 +	XSync(GFX_Display, False);
   14.80 +
   14.81 +	return(0);
   14.82 +
   14.83 +#else
   14.84 +    SDL_SetError("Gamma correction not supported on this visual");
   14.85 +    return(-1);
   14.86 +
   14.87 +#endif
   14.88 +}
   14.89 +
   14.90  static void DestroyScreen(_THIS)
   14.91  {
   14.92    	if(currently_fullscreen)
   14.93 @@ -98,20 +146,22 @@
   14.94  			this->hidden->SB[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL;
   14.95  
   14.96  			if(this->hidden->SB[1])
   14.97 +				FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
   14.98 +			if(this->hidden->SB[0])
   14.99  				FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
  14.100 -			if(this->hidden->SB[0])
  14.101 -				FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
  14.102  
  14.103  
  14.104  			this->hidden->SB[0]=this->hidden->SB[1]=NULL;
  14.105 -			free(SDL_RastPort);
  14.106 +
  14.107 +			if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort)
  14.108 +				free(SDL_RastPort);
  14.109 +
  14.110  			SDL_RastPort=NULL;
  14.111 -			this->hidden->dbuffer=0;
  14.112  		}
  14.113  		CloseScreen(GFX_Display);
  14.114  		currently_fullscreen=0;
  14.115  	}
  14.116 -	else
  14.117 +	else if(GFX_Display)
  14.118  		UnlockPubScreen(NULL,GFX_Display);
  14.119  
  14.120  	GFX_Display = NULL;
  14.121 @@ -121,11 +171,14 @@
  14.122  {
  14.123  	struct Library *l;
  14.124  
  14.125 -	l = OpenLibrary("cybergraphics.library",NULL);
  14.126 +	l = OpenLibrary("cybergraphics.library",0L);
  14.127  
  14.128  	if ( l != NULL ) {
  14.129 +		D(bug("CGX video device AVAILABLE\n"));
  14.130  		CloseLibrary(l);
  14.131  	}
  14.132 +	D(else bug("**CGX video device UNAVAILABLE\n"));
  14.133 +
  14.134  	return(l != NULL);
  14.135  }
  14.136  
  14.137 @@ -157,12 +210,13 @@
  14.138  	}
  14.139  	if ( (device == NULL) || (device->hidden == NULL) ||
  14.140  	                         (device->gl_data == NULL) ) {
  14.141 +		D(bug("Unable to create video device!\n"));
  14.142  		SDL_OutOfMemory();
  14.143  		CGX_DeleteDevice(device);
  14.144  		return(0);
  14.145  	}
  14.146 -	memset(device->hidden, 0, (sizeof *device->hidden));
  14.147 -	memset(device->gl_data, 0, (sizeof *device->gl_data));
  14.148 +	memset(device->hidden, 0, sizeof(*device->hidden));
  14.149 +	memset(device->gl_data, 0, sizeof(*device->gl_data));
  14.150  
  14.151  	/* Set the driver flags */
  14.152  	device->handles_any_size = 1;
  14.153 @@ -188,17 +242,21 @@
  14.154  	device->UnlockHWSurface = CGX_UnlockHWSurface;
  14.155  	device->FlipHWSurface = CGX_FlipHWSurface;
  14.156  	device->FreeHWSurface = CGX_FreeHWSurface;
  14.157 +	device->SetGamma = CGX_SetGamma;
  14.158 +	device->GetGamma = CGX_GetGamma;
  14.159 +	device->SetGammaRamp = CGX_SetGammaRamp;
  14.160 +	device->GetGammaRamp = NULL;
  14.161  #ifdef HAVE_OPENGL
  14.162 -	device->GL_LoadLibrary = X11_GL_LoadLibrary;
  14.163 -	device->GL_GetProcAddress = X11_GL_GetProcAddress;
  14.164 -	device->GL_GetAttribute = X11_GL_GetAttribute;
  14.165 -	device->GL_MakeCurrent = X11_GL_MakeCurrent;
  14.166 -	device->GL_SwapBuffers = X11_GL_SwapBuffers;
  14.167 +	device->GL_LoadLibrary = CGX_GL_LoadLibrary;
  14.168 +	device->GL_GetProcAddress = CGX_GL_GetProcAddress;
  14.169 +	device->GL_GetAttribute = CGX_GL_GetAttribute;
  14.170 +	device->GL_MakeCurrent = CGX_GL_MakeCurrent;
  14.171 +	device->GL_SwapBuffers = CGX_GL_SwapBuffers;
  14.172  #endif
  14.173  	device->SetIcon = CGX_SetIcon;
  14.174  	device->SetCaption = CGX_SetCaption;
  14.175  	device->IconifyWindow = NULL; /* CGX_IconifyWindow; */
  14.176 -	device->GrabInput = NULL /* CGX_GrabInput*/; 
  14.177 +	device->GrabInput = NULL /* CGX_GrabInput*/;
  14.178  	device->GetWMInfo = CGX_GetWMInfo;
  14.179  	device->FreeWMCursor = amiga_FreeWMCursor;
  14.180  	device->CreateWMCursor = amiga_CreateWMCursor;
  14.181 @@ -217,119 +275,13 @@
  14.182  	"CGX", "AmigaOS CyberGraphics", CGX_Available, CGX_CreateDevice
  14.183  };
  14.184  
  14.185 -#if 0
  14.186 -
  14.187 -/* Create auxiliary (toplevel) windows with the current visual */
  14.188 -static void create_aux_windows(_THIS)
  14.189 -{
  14.190 -    XSetWindowAttributes xattr;
  14.191 -    XWMHints *hints;
  14.192 -    XTextProperty titleprop, iconprop;
  14.193 -    int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen));
  14.194 -
  14.195 -    /* Don't create any extra windows if we are being managed */
  14.196 -    if ( SDL_windowid ) {
  14.197 -	FSwindow = 0;
  14.198 -	WMwindow = strtol(SDL_windowid, NULL, 0);
  14.199 -        return;
  14.200 -    }
  14.201 -
  14.202 -    if(FSwindow)
  14.203 -	XDestroyWindow(SDL_Display, FSwindow);
  14.204 -
  14.205 -    xattr.override_redirect = True;
  14.206 -    xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0;
  14.207 -    xattr.border_pixel = 0;
  14.208 -    xattr.colormap = SDL_XColorMap;
  14.209 -
  14.210 -    FSwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
  14.211 -			     this->hidden->depth, InputOutput, SDL_Visual,
  14.212 -			     CWOverrideRedirect | CWBackPixel | CWBorderPixel
  14.213 -			     | CWColormap,
  14.214 -			     &xattr);
  14.215 -
  14.216 -    XSelectInput(SDL_Display, FSwindow, StructureNotifyMask);
  14.217 -
  14.218 -    /* Tell KDE to keep the fullscreen window on top */
  14.219 -    {
  14.220 -	XEvent ev;
  14.221 -	long mask;
  14.222 -
  14.223 -	memset(&ev, 0, sizeof(ev));
  14.224 -	ev.xclient.type = ClientMessage;
  14.225 -	ev.xclient.window = SDL_Root;
  14.226 -	ev.xclient.message_type = XInternAtom(SDL_Display,
  14.227 -					      "KWM_KEEP_ON_TOP", False);
  14.228 -	ev.xclient.format = 32;
  14.229 -	ev.xclient.data.l[0] = FSwindow;
  14.230 -	ev.xclient.data.l[1] = CurrentTime;
  14.231 -	mask = SubstructureRedirectMask;
  14.232 -	XSendEvent(SDL_Display, SDL_Root, False, mask, &ev);
  14.233 -    }
  14.234 -
  14.235 -    hints = NULL;
  14.236 -    titleprop.value = iconprop.value = NULL;
  14.237 -    if(WMwindow) {
  14.238 -	/* All window attributes must survive the recreation */
  14.239 -	hints = XGetWMHints(SDL_Display, WMwindow);
  14.240 -	XGetWMName(SDL_Display, WMwindow, &titleprop);
  14.241 -	XGetWMIconName(SDL_Display, WMwindow, &iconprop);
  14.242 -	XDestroyWindow(SDL_Display, WMwindow);
  14.243 -    }
  14.244 -
  14.245 -    /* Create the window for windowed management */
  14.246 -    /* (reusing the xattr structure above) */
  14.247 -    WMwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
  14.248 -			     this->hidden->depth, InputOutput, SDL_Visual,
  14.249 -			     CWBackPixel | CWBorderPixel | CWColormap,
  14.250 -			     &xattr);
  14.251 -
  14.252 -    /* Set the input hints so we get keyboard input */
  14.253 -    if(!hints) {
  14.254 -	hints = XAllocWMHints();
  14.255 -	hints->input = True;
  14.256 -	hints->flags = InputHint;
  14.257 -    }
  14.258 -    XSetWMHints(SDL_Display, WMwindow, hints);
  14.259 -    XFree(hints);
  14.260 -    if(titleprop.value) {
  14.261 -	XSetWMName(SDL_Display, WMwindow, &titleprop);
  14.262 -	XFree(titleprop.value);
  14.263 -    }
  14.264 -    if(iconprop.value) {
  14.265 -	XSetWMIconName(SDL_Display, WMwindow, &iconprop);
  14.266 -	XFree(iconprop.value);
  14.267 -    }
  14.268 -
  14.269 -    XSelectInput(SDL_Display, WMwindow,
  14.270 -		 FocusChangeMask | KeyPressMask | KeyReleaseMask
  14.271 -		 | PropertyChangeMask | StructureNotifyMask);
  14.272 -
  14.273 -    /* Set the class hints so we can get an icon (AfterStep) */
  14.274 -    {
  14.275 -	XClassHint *classhints;
  14.276 -	classhints = XAllocClassHint();
  14.277 -	if(classhints != NULL) {
  14.278 -	    classhints->res_name = "SDL_App";
  14.279 -	    classhints->res_class = "SDL_App";
  14.280 -	    XSetClassHint(SDL_Display, WMwindow, classhints);
  14.281 -	    XFree(classhints);
  14.282 -	}
  14.283 -    }
  14.284 -
  14.285 -    /* Allow the window to be deleted by the window manager */
  14.286 -    WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
  14.287 -    XSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1);
  14.288 -}
  14.289 -#endif
  14.290 -
  14.291  Uint32 MakeBitMask(_THIS,int type,int format,int *bpp)
  14.292  {
  14.293  	D(if(type==0)bug("REAL pixel format: "));
  14.294  
  14.295  	if(this->hidden->depth==*bpp)
  14.296  	{
  14.297 -		
  14.298 +
  14.299  	switch(format)
  14.300      	{
  14.301  		case PIXFMT_LUT8:
  14.302 @@ -447,7 +399,7 @@
  14.303  	else
  14.304  	{
  14.305  		D(if(type==0)bug("DIFFERENT from screen.\nAllocated screen format: "));
  14.306 -	
  14.307 +
  14.308  		switch(*bpp)
  14.309  		{
  14.310  			case 32:
  14.311 @@ -479,43 +431,63 @@
  14.312  				D(if(type==0) bug("Not supported, switching to 24bit!\n"));
  14.313  				*bpp=24;
  14.314  				goto use_truecolor;
  14.315 -				break;				
  14.316 +				break;
  14.317  			default:
  14.318  				D(if(type==0)bug("This is a chunky display\n"));
  14.319  // For chunky display mask is always 0;
  14.320  				return 0;
  14.321  		}
  14.322 -	} 
  14.323 +	}
  14.324  	return 0;
  14.325  }
  14.326  
  14.327  static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat)
  14.328  {
  14.329  	int i;
  14.330 +	struct Library *RTGBase;
  14.331  
  14.332 -	if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39L)))
  14.333 -	{
  14.334 -		SDL_SetError("Couldn't open intuition V39+");
  14.335 -		return -1;
  14.336 +	D(bug("VideoInit... Opening libraries\n"));
  14.337 +
  14.338 +	if(!IntuitionBase) {
  14.339 +		if( !(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39L))) {
  14.340 +			SDL_SetError("Couldn't open intuition V39+");
  14.341 +			return -1;
  14.342 +		}
  14.343  	}
  14.344 -	if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39L)))
  14.345 -	{
  14.346 -		SDL_SetError("Couldn't open graphics V39+");
  14.347 -		return -1;
  14.348 +
  14.349 +	if(!GfxBase) {
  14.350 +		if( !(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39L))) {
  14.351 +			SDL_SetError("Couldn't open graphics V39+");
  14.352 +			return -1;
  14.353 +		}
  14.354  	}
  14.355 -	if(!(CyberGfxBase=OpenLibrary("cybergraphics.library",40L)))
  14.356 -	{
  14.357 -		SDL_SetError("Couldn't open cybergraphics.");
  14.358 -		return(-1);
  14.359 +
  14.360 +	if(!CyberGfxBase) {
  14.361 +		if( !(CyberGfxBase=OpenLibrary("cybergraphics.library",40L))) {
  14.362 +			SDL_SetError("Couldn't open cybergraphics.");
  14.363 +			return(-1);
  14.364 +		}
  14.365  	}
  14.366  
  14.367 +	if(RTGBase=OpenLibrary("libs:picasso96/rtg.library",0L)) {
  14.368 +		extern int use_picasso96;
  14.369 +
  14.370 +		CloseLibrary(RTGBase);
  14.371 +		use_picasso96=1;
  14.372 +	}
  14.373 +
  14.374 +	D(bug("Library intialized, locking screen...\n"));
  14.375 +
  14.376  	SDL_Display = LockPubScreen(NULL);
  14.377  
  14.378  	if ( SDL_Display == NULL ) {
  14.379 +		D(bug("Cannot lock display...\n"));
  14.380  		SDL_SetError("Couldn't lock the display");
  14.381  		return(-1);
  14.382  	}
  14.383  
  14.384 +	D(bug("Checking if we are using a CGX native display...\n"));
  14.385 +
  14.386  	if(!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort)))
  14.387  	{
  14.388  		Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,SDL_Display->Width,
  14.389 @@ -523,6 +495,8 @@
  14.390  				CYBRBIDTG_Depth,8,
  14.391  				TAG_DONE);
  14.392  
  14.393 +		D(bug("Default visual is not CGX native!\n"));
  14.394 +
  14.395  		UnlockPubScreen(NULL,SDL_Display);
  14.396  
  14.397  		GFX_Display=NULL;
  14.398 @@ -556,9 +530,11 @@
  14.399  // Non e' detto che sia cosi' pero', alcune schede potrebbero gestire i modi in modo differente
  14.400  
  14.401  	if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) {
  14.402 -			swap_pixels = 1;
  14.403 +		swap_pixels = 1;
  14.404  	}
  14.405  
  14.406 +	D(bug("Before GetVideoModes....\n"));
  14.407 +
  14.408  	/* Get the available video modes */
  14.409  	if(CGX_GetVideoModes(this) < 0)
  14.410  	    return -1;
  14.411 @@ -578,7 +554,7 @@
  14.412  //	SDL_XColorMap = SDL_DisplayColormap;
  14.413  
  14.414  	this->hidden->depth = this->hidden->visuals[i].depth;
  14.415 -	D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
  14.416 +	D(bug("Init: Setting screen depth to: %ld\n",this->hidden->depth));
  14.417  	vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */
  14.418  
  14.419  	{
  14.420 @@ -587,16 +563,21 @@
  14.421  		struct DisplayInfo info;
  14.422  
  14.423  		if(!(handle=FindDisplayInfo(this->hidden->visuals[i].visual)))
  14.424 +		{
  14.425 +			D(bug("Unable to get visual info...\n"));
  14.426  			return -1;
  14.427 +		}
  14.428  
  14.429 -		if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL))
  14.430 +		if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) {
  14.431 +			D(bug("Unable to get visual info data...\n"));
  14.432  			return -1;
  14.433 +		}
  14.434  
  14.435  		form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
  14.436  
  14.437  // In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask
  14.438  
  14.439 -		if ( vformat->BitsPerPixel > 8 ) 
  14.440 +		if ( vformat->BitsPerPixel > 8 )
  14.441  		{
  14.442  			vformat->Rmask = MakeBitMask(this,0,form,&this->hidden->depth);
  14.443  	  		vformat->Gmask = MakeBitMask(this,1,form,&this->hidden->depth);
  14.444 @@ -608,9 +589,6 @@
  14.445  /*	SDL_windowid = getenv("SDL_WINDOWID"); */
  14.446  	SDL_windowid=NULL;
  14.447  
  14.448 -	/* Create the fullscreen and managed windows */
  14.449 -//	create_aux_windows(this);
  14.450 -
  14.451  	/* Create the blank cursor */
  14.452  	SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR);
  14.453  
  14.454 @@ -625,16 +603,25 @@
  14.455  	this->hidden->same_format=0;
  14.456  	SDL_RastPort=&SDL_Display->RastPort;
  14.457  	/* We're done! */
  14.458 +	D(bug("End of CGX_VideoInit\n"));
  14.459 +
  14.460  	return(0);
  14.461  }
  14.462  
  14.463  void CGX_DestroyWindow(_THIS, SDL_Surface *screen)
  14.464  {
  14.465 +	D(bug("Destroy Window...\n"));
  14.466 +
  14.467  	if ( ! SDL_windowid ) {
  14.468  		/* Hide the managed window */
  14.469  		int was_fullscreen=0;
  14.470  
  14.471 -		if ( screen && (screen->flags & SDL_FULLSCREEN) ) {	
  14.472 +		/* Clean up OpenGL */
  14.473 +		if ( screen ) {
  14.474 +		screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT);
  14.475 +		}
  14.476 +
  14.477 +		if ( screen && (screen->flags & SDL_FULLSCREEN) ) {
  14.478  			was_fullscreen=1;
  14.479  			screen->flags &= ~SDL_FULLSCREEN;
  14.480  //			CGX_LeaveFullScreen(this); tolto x crash
  14.481 @@ -660,7 +647,7 @@
  14.482  
  14.483  				if(!was_fullscreen&&this->hidden->depth==8)
  14.484  				{
  14.485 -					for ( pixel=0; pixel<numcolors; pixel++ ) 
  14.486 +					for ( pixel=0; pixel<numcolors; pixel++ )
  14.487  					{
  14.488  						if(SDL_XPixels[pixel]>=0)
  14.489  							ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]);
  14.490 @@ -669,7 +656,7 @@
  14.491  			}
  14.492  			free(SDL_XPixels);
  14.493  			SDL_XPixels = NULL;
  14.494 -		} 
  14.495 +		}
  14.496  	}
  14.497  }
  14.498  
  14.499 @@ -701,6 +688,8 @@
  14.500  	int i, depth;
  14.501  	Uint32 vis;
  14.502  #endif
  14.503 +	D(bug("CGX_CreateWindow\n"));
  14.504 +
  14.505  	/* If a window is already present, destroy it and start fresh */
  14.506  	if ( SDL_Window ) {
  14.507  		CGX_DestroyWindow(this, screen);
  14.508 @@ -718,11 +707,11 @@
  14.509  /* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre
  14.510     hanno il pixel mode degli schermi.
  14.511   */
  14.512 -	if ( flags & SDL_OPENGL ) {
  14.513 +	/*if ( flags & SDL_OPENGL ) {
  14.514  		SDL_SetError("OpenGL not supported by the Amiga SDL!");
  14.515  		return -1;
  14.516 -	} 
  14.517 -	else {
  14.518 +	}
  14.519 +	else {*/
  14.520  		for ( i = 0; i < this->hidden->nvisuals; i++ ) {
  14.521  			if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */
  14.522  				break;
  14.523 @@ -733,10 +722,10 @@
  14.524  		}
  14.525  		vis = this->hidden->visuals[i].visual;
  14.526  		depth = this->hidden->visuals[i].depth;
  14.527 -	}
  14.528 +//	}
  14.529  	SDL_Visual = vis;
  14.530  	this->hidden->depth = depth;
  14.531 -	D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
  14.532 +	D(bug("Setting screen depth to: %ld\n",this->hidden->depth));
  14.533  #endif
  14.534  
  14.535  	/* Allocate the new pixel format for this video mode */
  14.536 @@ -766,7 +755,7 @@
  14.537  
  14.538  /* With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs
  14.539     only with requested format 15/16bit and display format != 15/16bit
  14.540 - */	
  14.541 + */
  14.542  
  14.543  		if ( ! SDL_ReallocFormat(screen, bpp,
  14.544  				MakeBitMask(this,0,form,&bpp), MakeBitMask(this,1,form,&bpp), MakeBitMask(this,2,form,&bpp), 0) )
  14.545 @@ -783,8 +772,8 @@
  14.546  	}
  14.547  */
  14.548  	if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) {
  14.549 -	    int ncolors;
  14.550 -	    D(bug("Alloco XPixels x la palette...\n"));
  14.551 +	    int ncolors,i;
  14.552 +	    D(bug("XPixels palette allocation...\n"));
  14.553  
  14.554  	    /* Allocate the pixel flags */
  14.555  
  14.556 @@ -794,52 +783,30 @@
  14.557  		ncolors = 1 << screen->format->BitsPerPixel;
  14.558  
  14.559  	    SDL_XPixels = (Sint32 *)malloc(ncolors * sizeof(Sint32));
  14.560 -		
  14.561 +
  14.562  	    if(SDL_XPixels == NULL) {
  14.563  		SDL_OutOfMemory();
  14.564  		return -1;
  14.565  	    }
  14.566  
  14.567 -	    memset(SDL_XPixels, -1, ncolors * sizeof(Sint32));
  14.568 +
  14.569 +	    for(i=0;i<ncolors;i++)
  14.570 +		    SDL_XPixels[i]=-1;
  14.571  
  14.572  	    /* always allocate a private colormap on non-default visuals */
  14.573  	    if(bpp==8)
  14.574  		flags |= SDL_HWPALETTE;
  14.575  
  14.576 -	    if ( flags & SDL_HWPALETTE ) {
  14.577 +	    if ( flags & SDL_HWPALETTE )
  14.578  			screen->flags |= SDL_HWPALETTE;
  14.579 -/*
  14.580 -			SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
  14.581 -		                                SDL_Visual, AllocAll);
  14.582 -*/
  14.583 -	    } else {
  14.584 -/*
  14.585 -			SDL_XColorMap = SDL_DisplayColormap;
  14.586 -*/
  14.587 -	    }
  14.588 -	} else {
  14.589 -/*
  14.590 -	    SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
  14.591 -	                                    SDL_Visual, AllocNone);
  14.592 -*/
  14.593 -	}
  14.594 -
  14.595 -	/* Recreate the auxiliary windows, if needed (required for GL) */
  14.596 -/*
  14.597 -	if ( vis_change )
  14.598 -	    create_aux_windows(this);
  14.599 -*/
  14.600 +	} 
  14.601  
  14.602  	/* resize the (possibly new) window manager window */
  14.603  
  14.604  	/* Create (or use) the X11 display window */
  14.605 +
  14.606  	if ( !SDL_windowid ) {
  14.607 -		if ( flags & SDL_OPENGL ) {
  14.608 -			return(-1);
  14.609 -		} 
  14.610 -		else 
  14.611 -		{
  14.612 -			if(flags & SDL_FULLSCREEN)
  14.613 +			if( flags & SDL_FULLSCREEN )
  14.614  			{
  14.615  				SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h,
  14.616  											WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE,
  14.617 @@ -847,27 +814,25 @@
  14.618  											WA_CustomScreen,(ULONG)SDL_Display,
  14.619  											TAG_DONE);
  14.620  
  14.621 -				D(bug("Apro finestra backdrop %ldx%ld su %lx!\n",w,h,SDL_Display));
  14.622 +				D(bug("Opening backdrop window %ldx%ld on display %lx!\n",w,h,SDL_Display));
  14.623  			}
  14.624  			else
  14.625  			{
  14.626 +				/* Create GimmeZeroZero window when OpenGL is used */
  14.627 +				unsigned long gzz = FALSE;
  14.628 +				if( flags & SDL_OPENGL ) {
  14.629 +					gzz = TRUE;
  14.630 +				}
  14.631 +
  14.632  				SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h,
  14.633  											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))),
  14.634  											WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE,
  14.635  											WA_PubScreen,(ULONG)SDL_Display,
  14.636 +											WA_GimmeZeroZero, gzz,
  14.637  														TAG_DONE);
  14.638 -				D(bug("Apro finestra %ldx%ld sul wb!\n",w,h));
  14.639 +				D(bug("Opening WB window of size: %ldx%ld!\n",w,h));
  14.640  			}
  14.641  
  14.642 -		}
  14.643 -		/* Only manage our input if we own the window */
  14.644 -/*
  14.645 -		XSelectInput(SDL_Display, SDL_Window,
  14.646 -					( EnterWindowMask | LeaveWindowMask
  14.647 -					| ButtonPressMask | ButtonReleaseMask
  14.648 -					| PointerMotionMask | ExposureMask ));
  14.649 -*/
  14.650 -
  14.651  		if(!SDL_Window)
  14.652  			return -1;
  14.653  	}
  14.654 @@ -885,17 +850,6 @@
  14.655  			return -1;
  14.656  	}
  14.657  	else SDL_RastPort=SDL_Window->RPort;
  14.658 -#if 0
  14.659 -
  14.660 -	if(screen->flags & SDL_HWPALETTE) {
  14.661 -	    /* Since the full-screen window might have got a nonzero background
  14.662 -	       colour (0 is white on some displays), we should reset the
  14.663 -	       background to 0 here since that is what the user expects
  14.664 -	       with a private colormap */
  14.665 -		SetAPen(SDL_Window->RPort,0);
  14.666 -		RectFill(SDL_Window->RPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,w+SDL_Window->BorderLeft,h+SDL_Window->BorderTop);
  14.667 -	}
  14.668 -#endif
  14.669  
  14.670  	if(flags&SDL_HWSURFACE)
  14.671  		screen->flags|=SDL_HWSURFACE;
  14.672 @@ -928,12 +882,28 @@
  14.673  	screen->pitch = SDL_CalculatePitch(screen);
  14.674  	CGX_ResizeImage(this, screen, flags);
  14.675  
  14.676 -	return(0);
  14.677 +	/* Make OpenGL Context if needed*/
  14.678 +	if(flags & SDL_OPENGL) {
  14.679 +		if(this->gl_data->gl_active == 0) {
  14.680 +			if(CGX_GL_Init(this) < 0)
  14.681 +				return -1;
  14.682 +			else
  14.683 +				screen->flags |= SDL_OPENGL;
  14.684 +		}
  14.685 +		else {
  14.686 +			if(CGX_GL_Update(this) < 0)
  14.687 +				return -1;
  14.688 +			else
  14.689 +				screen->flags |= SDL_OPENGL;
  14.690 +		}
  14.691 +	}
  14.692  }
  14.693  
  14.694  int CGX_ResizeWindow(_THIS,
  14.695  			SDL_Surface *screen, int w, int h, Uint32 flags)
  14.696  {
  14.697 +	D(bug("CGX_ResizeWindow\n"));
  14.698 +
  14.699  	if ( ! SDL_windowid ) {
  14.700  		/* Resize the window manager window */
  14.701  		CGX_SetSizeHints(this, w, h, flags);
  14.702 @@ -943,22 +913,6 @@
  14.703  		ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
  14.704  					h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
  14.705  
  14.706 -		/* Resize the fullscreen and display windows */
  14.707 -/*
  14.708 -		if ( flags & SDL_FULLSCREEN ) {
  14.709 -			if ( screen->flags & SDL_FULLSCREEN ) {
  14.710 -				CGX_ResizeFullScreen(this);
  14.711 -			} else {
  14.712 -				screen->flags |= SDL_FULLSCREEN;
  14.713 -				CGX_EnterFullScreen(this);
  14.714 -			}
  14.715 -		} else {
  14.716 -			if ( screen->flags & SDL_FULLSCREEN ) {
  14.717 -				screen->flags &= ~SDL_FULLSCREEN;
  14.718 -				CGX_LeaveFullScreen(this);
  14.719 -			}
  14.720 -		}
  14.721 -*/
  14.722  		screen->w = w;
  14.723  		screen->h = h;
  14.724  		screen->pitch = SDL_CalculatePitch(screen);
  14.725 @@ -973,23 +927,25 @@
  14.726  	Uint32 saved_flags;
  14.727  	int needcreate=0;
  14.728  
  14.729 +	D(bug("CGX_SetVideoMode current:%lx\n",current));
  14.730 +
  14.731  	/* Lock the event thread, in multi-threading environments */
  14.732  	SDL_Lock_EventThread();
  14.733  
  14.734  // Check if the window needs to be closed or can be resized
  14.735  
  14.736 -	if( (flags&SDL_FULLSCREEN) || (current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)))
  14.737 +	if( (flags&SDL_FULLSCREEN) || (current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)))
  14.738  		needcreate=1;
  14.739  
  14.740 -// Check if we need to close an already existing videomode... 
  14.741 +// Check if we need to close an already existing videomode...
  14.742  
  14.743 -	if(current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN))
  14.744 -	{
  14.745 +	if(current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)) {
  14.746  		unsigned long i;
  14.747 +		D(bug("Destroying image, window & screen!\n"));
  14.748 +
  14.749  		CGX_DestroyImage(this,current);
  14.750  		CGX_DestroyWindow(this,current);
  14.751  		DestroyScreen(this);
  14.752 -		D(bug("Distrutte immagine, finestra e schermo!\n"));
  14.753  		GFX_Display=SDL_Display=LockPubScreen(NULL);
  14.754  
  14.755  		bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
  14.756 @@ -1004,23 +960,23 @@
  14.757  		}
  14.758  		SDL_Visual = this->hidden->visuals[i].visual;
  14.759  
  14.760 -		D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
  14.761 -		
  14.762 +		D(bug("Setting screen depth to: %ld\n",this->hidden->depth));
  14.763 +
  14.764  	}
  14.765  	/* Check the combination of flags we were passed */
  14.766  	if ( flags & SDL_FULLSCREEN ) {
  14.767  		int i;
  14.768 -	
  14.769 +
  14.770  		/* Clear fullscreen flag if not supported */
  14.771  		if ( SDL_windowid ) {
  14.772  			flags &= ~SDL_FULLSCREEN;
  14.773  		}
  14.774 -		else if(current->flags&SDL_FULLSCREEN )
  14.775 -		{
  14.776 +		else if(current && current->flags&SDL_FULLSCREEN ) {
  14.777  			if(current->w!=width ||
  14.778  				current->h!=height ||
  14.779 -				this->hidden->depth!=bpp)
  14.780 +				(this->hidden && this->hidden->depth!=bpp))
  14.781  			{
  14.782 +				D(bug("Deleting previous window...\n"));
  14.783  				CGX_DestroyImage(this,current);
  14.784  				CGX_DestroyWindow(this,current);
  14.785  				DestroyScreen(this);
  14.786 @@ -1037,8 +993,9 @@
  14.787  
  14.788  			GFX_Display=NULL;
  14.789  
  14.790 +			D(bug("Opening screen...\n"));
  14.791 +
  14.792  			if(okid!=INVALID_ID)
  14.793 -			{
  14.794  				GFX_Display=OpenScreenTags(NULL,
  14.795  								SA_Width,width,
  14.796  								SA_Height,height,
  14.797 @@ -1046,58 +1003,50 @@
  14.798  								SA_Depth,bpp,
  14.799  								SA_DisplayID,okid,
  14.800  								TAG_DONE);
  14.801 -			}
  14.802  
  14.803 -
  14.804 -			if(!GFX_Display)
  14.805 -			{
  14.806 +			if(!GFX_Display) {
  14.807  				GFX_Display=SDL_Display;
  14.808  				flags &= ~SDL_FULLSCREEN;
  14.809  				flags &= ~SDL_DOUBLEBUF;
  14.810  			}
  14.811 -			else
  14.812 -			{
  14.813 +			else {
  14.814  				UnlockPubScreen(NULL,SDL_Display);
  14.815  				SDL_Display=GFX_Display;
  14.816 +	
  14.817 +				D(bug("Screen opened.\n"));
  14.818  
  14.819 -				if(flags&SDL_DOUBLEBUF)
  14.820 -				{
  14.821 +				if(flags&SDL_DOUBLEBUF) {
  14.822  					int ok=0;
  14.823 +					D(bug("Start of DBuffering allocations...\n"));
  14.824  
  14.825 -					if(this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP))
  14.826 -					{
  14.827 -						if(this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,0L))
  14.828 -						{
  14.829 +					if(this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP)) {
  14.830 +
  14.831 +						if(this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,0L)) {
  14.832  							extern struct MsgPort *safeport,*dispport;
  14.833  
  14.834  							safeport=CreateMsgPort();
  14.835  							dispport=CreateMsgPort();
  14.836  
  14.837 -							if(!safeport || !dispport)
  14.838 -							{
  14.839 -								if(safeport)
  14.840 -								{
  14.841 +							if(!safeport || !dispport) {
  14.842 +								if(safeport) {
  14.843  									DeleteMsgPort(safeport);
  14.844  									safeport=NULL;
  14.845  								}
  14.846 -								if(dispport)
  14.847 -								{
  14.848 +								if(dispport) {
  14.849  									DeleteMsgPort(dispport);
  14.850  									dispport=NULL;
  14.851  								}
  14.852  								FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
  14.853  								FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
  14.854  							}
  14.855 -							else
  14.856 -							{
  14.857 +							else {
  14.858  								extern ULONG safe_sigbit,disp_sigbit;
  14.859  								int i;
  14.860  
  14.861  								safe_sigbit=1L<< safeport->mp_SigBit;
  14.862  								disp_sigbit=1L<< dispport->mp_SigBit;
  14.863 -	
  14.864 -								for(i=0;i<2;i++)
  14.865 -								{
  14.866 +
  14.867 +								for(i=0;i<2;i++) {
  14.868  									this->hidden->SB[i]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=safeport;
  14.869  									this->hidden->SB[i]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=dispport;
  14.870  								}
  14.871 @@ -1108,31 +1057,28 @@
  14.872  								current->flags|=SDL_DOUBLEBUF;
  14.873  							}
  14.874  						}
  14.875 -						else 
  14.876 -						{
  14.877 +						else {
  14.878  							FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
  14.879  							this->hidden->SB[0]=NULL;
  14.880  						}
  14.881  					}
  14.882  
  14.883  					if(!ok)
  14.884 -					{
  14.885  						flags&=~SDL_DOUBLEBUF;
  14.886 -					}
  14.887  				}
  14.888  			}
  14.889  
  14.890  			if(GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)==bpp)
  14.891 -				this->hidden->same_format=1;				
  14.892 +				this->hidden->same_format=1;
  14.893  		}
  14.894  
  14.895  		bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
  14.896 -		D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
  14.897 +		D(bug("Setting screen depth to: %ld\n",this->hidden->depth));
  14.898  
  14.899 -		for ( i = 0; i < this->hidden->nvisuals; i++ ) {
  14.900 +		for ( i = 0; i < this->hidden->nvisuals; i++ )
  14.901  			if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */
  14.902  				break;
  14.903 -		}
  14.904 +
  14.905  		if ( i == this->hidden->nvisuals ) {
  14.906  			SDL_SetError("No matching visual for requested depth");
  14.907  			return NULL;	/* should never happen */
  14.908 @@ -1202,11 +1148,14 @@
  14.909  		this->screen->flags &= ~SDL_FULLSCREEN;
  14.910  		CGX_LeaveFullScreen(this);
  14.911  	}
  14.912 +
  14.913  	CGX_RefreshDisplay(this);
  14.914  	if ( event_thread ) {
  14.915  		SDL_Unlock_EventThread();
  14.916  	}
  14.917 +
  14.918  	SDL_ResetKeyboard();
  14.919 +
  14.920  	return(1);
  14.921  }
  14.922  
  14.923 @@ -1274,7 +1223,7 @@
  14.924  			break;
  14.925  
  14.926  		default:
  14.927 -			D(bug("Errore, SetSingleColor con PIXFMT %ld!\n",fmt));
  14.928 +			D(bug("Error, SetSingleColor with PIXFMT %ld!\n",fmt));
  14.929  	}
  14.930  }
  14.931  
  14.932 @@ -1292,11 +1241,11 @@
  14.933  	else
  14.934  	{
  14.935  		if(	SDL_Display->MouseX>=(SDL_Window->LeftEdge+SDL_Window->BorderLeft) && SDL_Display->MouseX<(SDL_Window->LeftEdge+SDL_Window->Width-SDL_Window->BorderRight) &&
  14.936 -			SDL_Display->MouseY>=(SDL_Window->TopEdge+SDL_Window->BorderLeft) && SDL_Display->MouseY<(SDL_Window->TopEdge+SDL_Window->Height-SDL_Window->BorderBottom) 
  14.937 +			SDL_Display->MouseY>=(SDL_Window->TopEdge+SDL_Window->BorderLeft) && SDL_Display->MouseY<(SDL_Window->TopEdge+SDL_Window->Height-SDL_Window->BorderBottom)
  14.938  			)
  14.939  		{
  14.940  			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
  14.941 -			SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft, 
  14.942 +			SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft,
  14.943  										SDL_Display->MouseY-SDL_Window->TopEdge-SDL_Window->BorderTop);
  14.944  		}
  14.945  		else
  14.946 @@ -1314,7 +1263,7 @@
  14.947  	/* Check to make sure we have a colormap allocated */
  14.948  
  14.949  	/* It's easy if we have a hidden colormap */
  14.950 -	if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) 
  14.951 +	if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen )
  14.952  	{
  14.953  		ULONG  xcmap[256*3+2];
  14.954  
  14.955 @@ -1343,7 +1292,7 @@
  14.956  		{
  14.957  // In this case I have to unalloc and realloc the full palette
  14.958  			D(bug("Obtaining %ld colors on the screen\n",ncolors));
  14.959 -	
  14.960 +
  14.961  		/* Free existing allocated colors */
  14.962  			for ( pixel=0; pixel<this->screen->format->palette->ncolors; ++pixel ) {
  14.963  				if(SDL_XPixels[pixel]>=0)
  14.964 @@ -1356,7 +1305,7 @@
  14.965  			}
  14.966  		}
  14.967  		else
  14.968 -		{			
  14.969 +		{
  14.970  #ifndef USE_CGX_WRITELUTPIXEL
  14.971  			Uint32 fmt;
  14.972  			D(bug("Preparing a conversion pixel table...\n"));
  14.973 @@ -1368,7 +1317,7 @@
  14.974  				SetSingleColor(fmt,colors[firstcolor+i].r,colors[firstcolor+i].g,colors[firstcolor+i].b,(unsigned char *)&SDL_XPixels[firstcolor+i]);
  14.975  			}
  14.976  #else
  14.977 -//			D(bug("Eseguo remap degli XPixel(%lx): (da %ld, %ld colori) primo: r%ld g%ld b%ld\n",SDL_XPixels,firstcolor,ncolors,colors[firstcolor].r,colors[firstcolor].g,colors[firstcolor].b));
  14.978 +//			D(bug("Executing XPixel(%lx) remapping: (from %ld, %ld colors) first: r%ld g%ld b%ld\n",SDL_XPixels,firstcolor,ncolors,colors[firstcolor].r,colors[firstcolor].g,colors[firstcolor].b));
  14.979  			for(i=0;i<ncolors;i++)
  14.980  				SDL_XPixels[i+firstcolor]=(colors[firstcolor+i].r<<16)+(colors[firstcolor+i].g<<8)+colors[firstcolor+i].b;
  14.981  #endif
  14.982 @@ -1387,32 +1336,23 @@
  14.983  {
  14.984  	/* Shutdown everything that's still up */
  14.985  	/* The event thread should be done, so we can touch SDL_Display */
  14.986 +	D(bug("CGX_VideoQuit\n"));
  14.987 +
  14.988  	if ( SDL_Display != NULL ) {
  14.989  		/* Clean up OpenGL */
  14.990 -
  14.991 +		if(this->gl_data->gl_active == 1) {
  14.992 +			CGX_GL_Quit(this);
  14.993 +		}
  14.994  		/* Start shutting down the windows */
  14.995 +		D(bug("Destroying image...\n"));
  14.996  		CGX_DestroyImage(this, this->screen);
  14.997 +		D(bug("Destroying window...\n"));
  14.998  		CGX_DestroyWindow(this, this->screen);
  14.999  // Otherwise SDL_VideoQuit will try to free it!
 14.1000  		SDL_VideoSurface=NULL;
 14.1001 +
 14.1002  		CGX_FreeVideoModes(this);
 14.1003  
 14.1004 -/*
 14.1005 -		if ( SDL_iconcolors ) {
 14.1006 -			unsigned long pixel;
 14.1007 -			int numcolors =
 14.1008 -				((this->screen->format)->palette)->ncolors;
 14.1009 -			for ( pixel=0; pixel<numcolors; ++pixel ) {
 14.1010 -				while ( SDL_iconcolors[pixel] > 0 ) {
 14.1011 -					XFreeColors(SDL_Display,
 14.1012 -						SDL_DisplayColormap,&pixel,1,0);
 14.1013 -					--SDL_iconcolors[pixel];
 14.1014 -				}
 14.1015 -			}
 14.1016 -			free(SDL_iconcolors);
 14.1017 -			SDL_iconcolors = NULL;
 14.1018 -		} 
 14.1019 -*/
 14.1020  		/* Free that blank cursor */
 14.1021  		if ( SDL_BlankCursor != NULL ) {
 14.1022  			FreeMem(SDL_BlankCursor,16);
 14.1023 @@ -1422,6 +1362,8 @@
 14.1024  		/* Close the X11 graphics connection */
 14.1025  		this->hidden->same_format=0;
 14.1026  
 14.1027 +		D(bug("Destroying screen...\n"));
 14.1028 +
 14.1029  		if ( GFX_Display != NULL )
 14.1030  			DestroyScreen(this);
 14.1031  
 14.1032 @@ -1431,19 +1373,18 @@
 14.1033  		/* Unload GL library after X11 shuts down */
 14.1034  	}
 14.1035  
 14.1036 -	if( CyberGfxBase)
 14.1037 -	{
 14.1038 +	D(bug("Closing libraries...\n"));
 14.1039 +
 14.1040 +	if( CyberGfxBase) {
 14.1041  		CloseLibrary(CyberGfxBase);
 14.1042  		CyberGfxBase=NULL;
 14.1043  	}
 14.1044  
 14.1045 -	if (IntuitionBase)
 14.1046 -	{
 14.1047 +	if (IntuitionBase) {
 14.1048  		CloseLibrary((struct Library *)IntuitionBase);
 14.1049  		IntuitionBase=NULL;
 14.1050  	}
 14.1051 -	if (GfxBase)
 14.1052 -	{
 14.1053 +	if (GfxBase) {
 14.1054  		CloseLibrary((struct Library *)GfxBase);
 14.1055  		GfxBase=NULL;
 14.1056  	}
 14.1057 @@ -1452,5 +1393,7 @@
 14.1058  		/* Direct screen access, no memory buffer */
 14.1059  		this->screen->pixels = NULL;
 14.1060  	}
 14.1061 +	D(bug("End of CGX_VideoQuit.\n"));
 14.1062 +
 14.1063  }
 14.1064  
    15.1 --- a/src/video/cybergfx/SDL_cgxvideo.h	Fri Dec 14 13:13:20 2001 +0000
    15.2 +++ b/src/video/cybergfx/SDL_cgxvideo.h	Sun Dec 16 20:00:27 2001 +0000
    15.3 @@ -38,7 +38,7 @@
    15.4  #include <graphics/scale.h>
    15.5  #include <graphics/gfx.h>
    15.6  #include <intuition/intuition.h>
    15.7 -#ifdef __SASC
    15.8 +#if defined(__SASC) || defined(STORMC4_WOS)
    15.9  #include <proto/exec.h>
   15.10  #include <proto/cybergraphics.h>
   15.11  #include <proto/graphics.h>
   15.12 @@ -177,6 +177,7 @@
   15.13  	APTR lock;
   15.14  	struct SDL_VideoDevice *videodata;
   15.15  	APTR mask;
   15.16 +	int allocated;
   15.17  };
   15.18  
   15.19  int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst);