Mercurial > sdl-ios-xcode
changeset 3888:6d2e1961661a SDL-1.2
Removed broken AmigaOS support.
Fixes Bugzilla #337.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sun, 29 Oct 2006 03:58:27 +0000 |
parents | 9dcceea84416 |
children | 67d518069d9a |
files | BUGS README README.AmigaOS include/SDL_config.h.default include/SDL_config.h.in include/SDL_config_amiga.h include/SDL_platform.h src/audio/SDL_audio.c src/audio/amigaos/SDL_ahiaudio.c src/audio/amigaos/SDL_ahiaudio.h src/joystick/amigaos/SDL_sysjoystick.c src/thread/SDL_thread_c.h src/thread/amigaos/SDL_syssem.c src/thread/amigaos/SDL_systhread.c src/thread/amigaos/SDL_systhread_c.h src/thread/amigaos/SDL_thread.c src/timer/amigaos/SDL_systimer.c src/video/SDL_video.c src/video/cybergfx/SDL_amigaevents.c src/video/cybergfx/SDL_amigaevents_c.h src/video/cybergfx/SDL_amigamouse.c src/video/cybergfx/SDL_amigamouse_c.h src/video/cybergfx/SDL_cgxaccel.c src/video/cybergfx/SDL_cgxgl.c src/video/cybergfx/SDL_cgxgl_c.h src/video/cybergfx/SDL_cgximage.c src/video/cybergfx/SDL_cgximage_c.h src/video/cybergfx/SDL_cgxmodes.c src/video/cybergfx/SDL_cgxmodes_c.h src/video/cybergfx/SDL_cgxvideo.c src/video/cybergfx/SDL_cgxvideo.h src/video/cybergfx/SDL_cgxwm.c src/video/cybergfx/SDL_cgxwm_c.h test/testplatform.c |
diffstat | 34 files changed, 10 insertions(+), 5910 deletions(-) [+] |
line wrap: on
line diff
--- a/BUGS Sun Oct 29 03:44:25 2006 +0000 +++ b/BUGS Sun Oct 29 03:58:27 2006 +0000 @@ -190,15 +190,3 @@ More information on this port is available at: http://www.kom.e-technik.tu-darmstadt.de/~griff/SDL/ -AmigaOS: -= NOT YET SUPPORTED =- - The OpenGL support isn't implemented yet. - - SDL_WM_GrabInput() is not implemented. - Does anyone know how to do this? SDL_WM_GrabInput() is designed - to prevent the user from switching input and mouse focus away from - the SDL application. - - Continuous relative mouse motion is not implemented. - - The AmigaOS port was done by Gabriele.Greco@galactica.it -
--- a/README Sun Oct 29 03:44:25 2006 +0000 +++ b/README Sun Oct 29 03:58:27 2006 +0000 @@ -14,7 +14,7 @@ The current version supports Linux, Windows, Windows CE, BeOS, MacOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. -The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64, +The code contains support for Dreamcast, Atari, AIX, OSF/Tru64, RISC OS, SymbianOS, and OS/2, but these are not officially supported. SDL is written in C, but works with C++ natively, and has bindings to
--- a/README.AmigaOS Sun Oct 29 03:44:25 2006 +0000 +++ b/README.AmigaOS Sun Oct 29 03:58:27 2006 +0000 @@ -1,50 +1,12 @@ -This is the porting of 1.2.0 version of SDL (the latest stable one) -to AmigaOS/68k. - -All the bugs known of the past version have been corrected. And I've -added all the new SDL features. - -This version of SDL needs Cybergraphx V3 (r69+) or CyberGraphX V4 -and AHI v3+. Probably it works also with P96 or CGXAga, but it's -untested. - -This version is available as linked library for SAS/C and GCC, only 68k this -time, a powerup (ppcemu compatible) and a morphos version will be ready quite -soon (i hope). - -Implemented: +The AmigaOS code has been removed from SDL, since it had been broken for a + long time and had a few bits of fairly invasive code #ifdef'd into the + SDL core. -- 8/16/24/32bit video modes, both fullscreen and windowed. -- Hardware surfaces. -- CGX blitting acceleration. -- CGX colorkey blitting acceleration. -- AHI audio (8/16 bit, with any audio format), always uses unit 0 for now. -- Thread support (maybe not 100% compatible with other implementations) -- Semaphores -- Window resizing and backdrop windows (NEW) -- Joystick/Joypad support. - -To do: - -- CDRom audio playing support -- OpenGL (A guy was working on it but I've lost his tracks :( ) +However, there is an OS4 version of SDL here: + http://www.rcdrummond.net/amiga/index.html -The SAS/C library is distributed with debug info attached, to strip debug info -simply add STRIPDEBUG argument to the linker. - -NOTE: SDL includes debug output using kprintf, to disable it add to your -project a function like this: - -void kprintf(char *a,...) -{ -} +And a MorphOS version here: + http://www.lehtoranta.net/powersdl/ -Otherwise you can redirect the debug to a console window with sushi, sashimi or -similar tools (the default output is the internal serial port). - -For info, support, bugfix and other feel free to mail me: +--ryan. -Gabriele Greco (gabriele.greco@aruba.it) - -You can find also a small SDL Amiga page at: -http://ggreco.interfree.it/sdl.html
--- a/include/SDL_config.h.default Sun Oct 29 03:44:25 2006 +0000 +++ b/include/SDL_config.h.default Sun Oct 29 03:58:27 2006 +0000 @@ -26,9 +26,7 @@ #include "SDL_platform.h" /* Add any platform that doesn't build using the configure system */ -#if defined(__AMIGA__) -#include "SDL_config_amiga.h" -#elif defined(__DREAMCAST__) +#if defined(__DREAMCAST__) #include "SDL_config_dreamcast.h" #elif defined(__MACOS__) #include "SDL_config_macos.h"
--- a/include/SDL_config.h.in Sun Oct 29 03:44:25 2006 +0000 +++ b/include/SDL_config.h.in Sun Oct 29 03:58:27 2006 +0000 @@ -195,7 +195,6 @@ /* Enable various input drivers */ #undef SDL_INPUT_TSLIB -#undef SDL_JOYSTICK_AMIGA #undef SDL_JOYSTICK_BEOS #undef SDL_JOYSTICK_DC #undef SDL_JOYSTICK_DUMMY @@ -221,7 +220,6 @@ #undef SDL_LOADSO_WIN32 /* Enable various threading systems */ -#undef SDL_THREAD_AMIGA #undef SDL_THREAD_BEOS #undef SDL_THREAD_DC #undef SDL_THREAD_EPOC @@ -234,7 +232,6 @@ #undef SDL_THREAD_WIN32 /* Enable various timer systems */ -#undef SDL_TIMER_AMIGA #undef SDL_TIMER_BEOS #undef SDL_TIMER_DC #undef SDL_TIMER_DUMMY
--- a/include/SDL_config_amiga.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_amiga_h -#define _SDL_config_amiga_h - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -#define SDL_HAS_64BIT_TYPE 1 - -/* Useful headers */ -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_AHI 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various cdrom drivers */ -#define SDL_CDROM_DUMMY 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_AMIGA 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_DUMMY 1 - -/* Enable various threading systems */ -#define SDL_THREAD_AMIGA 1 - -/* Enable various timer systems */ -#define SDL_TIMER_AMIGA 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_CYBERGRAPHICS 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 - -/* Enable OpenGL support */ -#define SDL_VIDEO_OPENGL 1 - -#endif /* _SDL_config_amiga_h */
--- a/include/SDL_platform.h Sun Oct 29 03:44:25 2006 +0000 +++ b/include/SDL_platform.h Sun Oct 29 03:58:27 2006 +0000 @@ -29,10 +29,6 @@ #undef __AIX__ #define __AIX__ 1 #endif -#if defined(AMIGA) || defined(__AMIGA) || defined(__amigados__) -#undef __AMIGA__ -#define __AMIGA__ 1 -#endif #if defined(__BEOS__) #undef __BEOS__ #define __BEOS__ 1
--- a/src/audio/SDL_audio.c Sun Oct 29 03:44:25 2006 +0000 +++ b/src/audio/SDL_audio.c Sun Oct 29 03:58:27 2006 +0000 @@ -82,9 +82,6 @@ #if SDL_AUDIO_DRIVER_SNDMGR &SNDMGR_bootstrap, #endif -#if SDL_AUDIO_DRIVER_AHI - &AHI_bootstrap, -#endif #if SDL_AUDIO_DRIVER_MINT &MINTAUDIO_GSXB_bootstrap, &MINTAUDIO_MCSN_bootstrap, @@ -115,10 +112,6 @@ int SDL_AudioInit(const char *driver_name); void SDL_AudioQuit(void); -#if SDL_AUDIO_DRIVER_AHI -static int audio_configured = 0; -#endif - /* The general mixing thread function */ int SDLCALL SDL_RunAudio(void *audiop) { @@ -128,21 +121,6 @@ void *udata; void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len); int silence; -#if SDL_AUDIO_DRIVER_AHI - int started = 0; - -/* AmigaOS NEEDS that the audio driver is opened in the thread that uses it! */ - - D(bug("Task audio started audio struct:<%lx>...\n",audiop)); - - D(bug("Before Openaudio...")); - if(audio->OpenAudio(audio, &audio->spec)==-1) - { - D(bug("Open audio failed...\n")); - return(-1); - } - D(bug("OpenAudio...OK\n")); -#endif /* Perform any thread setup */ if ( audio->ThreadInit ) { @@ -154,14 +132,6 @@ fill = audio->spec.callback; udata = audio->spec.userdata; -#if SDL_AUDIO_DRIVER_AHI - audio_configured = 1; - - D(bug("Audio configured... Checking for conversion\n")); - SDL_mutexP(audio->mixer_lock); - D(bug("Semaphore obtained...\n")); -#endif - if ( audio->convert.needed ) { if ( audio->convert.src_format == AUDIO_U8 ) { silence = 0x80; @@ -174,11 +144,6 @@ stream_len = audio->spec.size; } -#if SDL_AUDIO_DRIVER_AHI - SDL_mutexV(audio->mixer_lock); - D(bug("Entering audio loop...\n")); -#endif - #ifdef __OS2__ /* Increase the priority of this thread to make sure that the audio will be continuous all the time! */ @@ -253,14 +218,6 @@ audio->WaitDone(audio); } -#if SDL_AUDIO_DRIVER_AHI - D(bug("WaitAudio...Done\n")); - - audio->CloseAudio(audio); - - D(bug("CloseAudio..Done, subtask exiting...\n")); - audio_configured = 0; -#endif #ifdef __OS2__ #ifdef DEBUG_BUILD printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID()); @@ -532,33 +489,12 @@ audio->enabled = 1; audio->paused = 1; -#if !SDL_AUDIO_DRIVER_AHI - -/* AmigaOS opens audio inside the main loop */ audio->opened = audio->OpenAudio(audio, &audio->spec)+1; if ( ! audio->opened ) { SDL_CloseAudio(); return(-1); } -#else - D(bug("Locking semaphore...")); - SDL_mutexP(audio->mixer_lock); - - - audio->thread = SDL_CreateThread(SDL_RunAudio, audio); - D(bug("Created thread...\n")); - - if ( audio->thread == NULL ) { - SDL_mutexV(audio->mixer_lock); - SDL_CloseAudio(); - SDL_SetError("Couldn't create audio thread"); - return(-1); - } - - while(!audio_configured) - SDL_Delay(100); -#endif /* If the audio driver changes the buffer size, accept it */ if ( audio->spec.samples != desired->samples ) { @@ -602,7 +538,6 @@ } } -#if !SDL_AUDIO_DRIVER_AHI /* Start the audio thread if necessary */ switch (audio->opened) { case 1: @@ -624,11 +559,6 @@ /* The audio is now playing */ break; } -#else - SDL_mutexV(audio->mixer_lock); - D(bug("SDL_OpenAudio USCITA...\n")); - -#endif return(0); } @@ -702,12 +632,10 @@ SDL_FreeAudioMem(audio->convert.buf); } -#if !SDL_AUDIO_DRIVER_AHI if ( audio->opened ) { audio->CloseAudio(audio); audio->opened = 0; } -#endif /* Free the driver data */ audio->free(audio); current_audio = NULL;
--- a/src/audio/amigaos/SDL_ahiaudio.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,340 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Allow access to a raw mixing buffer (for AmigaOS) */ - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "SDL_ahiaudio.h" - -/* Audio driver functions */ -static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec); -static void AHI_WaitAudio(_THIS); -static void AHI_PlayAudio(_THIS); -static Uint8 *AHI_GetAudioBuf(_THIS); -static void AHI_CloseAudio(_THIS); - -#ifndef __SASC - #define mymalloc(x) AllocVec(x,MEMF_PUBLIC) - #define myfree FreeVec -#else - #define mymalloc malloc - #define myfree free -#endif - -/* Audio driver bootstrap functions */ - -static int Audio_Available(void) -{ - int ok=0; - struct MsgPort *p; - struct AHIRequest *req; - - if(p=CreateMsgPort()) - { - if(req=(struct AHIRequest *)CreateIORequest(p,sizeof(struct AHIRequest))) - { - req->ahir_Version=4; - - if(!OpenDevice(AHINAME,0,(struct IORequest *)req,NULL)) - { - D(bug("AHI available.\n")); - ok=1; - CloseDevice((struct IORequest *)req); - } - DeleteIORequest((struct IORequest *)req); - } - DeleteMsgPort(p); - } - - D(if(!ok) bug("AHI not available\n")); - return ok; -} - -static void Audio_DeleteDevice(SDL_AudioDevice *device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_AudioDevice *Audio_CreateDevice(int devindex) -{ - SDL_AudioDevice *this; - -#ifndef NO_AMIGADEBUG - D(bug("AHI created...\n")); -#endif - - /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); - if ( this ) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - } - if ( (this == NULL) || (this->hidden == NULL) ) { - SDL_OutOfMemory(); - if ( this ) { - SDL_free(this); - } - return(0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Set the function pointers */ - this->OpenAudio = AHI_OpenAudio; - this->WaitAudio = AHI_WaitAudio; - this->PlayAudio = AHI_PlayAudio; - this->GetAudioBuf = AHI_GetAudioBuf; - this->CloseAudio = AHI_CloseAudio; - - this->free = Audio_DeleteDevice; - - return this; -} - -AudioBootStrap AHI_bootstrap = { - "AHI", Audio_Available, Audio_CreateDevice -}; - - -void static AHI_WaitAudio(_THIS) -{ - if(!CheckIO((struct IORequest *)audio_req[current_buffer])) - { - WaitIO((struct IORequest *)audio_req[current_buffer]); -// AbortIO((struct IORequest *)audio_req[current_buffer]); - } -} - -static void AHI_PlayAudio(_THIS) -{ - if(playing>1) - WaitIO((struct IORequest *)audio_req[current_buffer]); - - /* Write the audio data out */ - audio_req[current_buffer] -> ahir_Std. io_Message.mn_Node.ln_Pri = 60; - audio_req[current_buffer] -> ahir_Std. io_Data = mixbuf[current_buffer]; - audio_req[current_buffer] -> ahir_Std. io_Length = this->hidden->size; - audio_req[current_buffer] -> ahir_Std. io_Offset = 0; - audio_req[current_buffer] -> ahir_Std . io_Command = CMD_WRITE; - audio_req[current_buffer] -> ahir_Frequency = this->hidden->freq; - audio_req[current_buffer] -> ahir_Volume = 0x10000; - audio_req[current_buffer] -> ahir_Type = this->hidden->type; - audio_req[current_buffer] -> ahir_Position = 0x8000; - audio_req[current_buffer] -> ahir_Link = (playing>0 ? audio_req[current_buffer^1] : NULL); - - SendIO((struct IORequest *)audio_req[current_buffer]); - current_buffer^=1; - - playing++; -} - -static Uint8 *AHI_GetAudioBuf(_THIS) -{ - return(mixbuf[current_buffer]); -} - -static void AHI_CloseAudio(_THIS) -{ - D(bug("Closing audio...\n")); - - playing=0; - - if(audio_req[0]) - { - if(audio_req[1]) - { - D(bug("Break req[1]...\n")); - - AbortIO((struct IORequest *)audio_req[1]); - WaitIO((struct IORequest *)audio_req[1]); - } - - D(bug("Break req[0]...\n")); - - AbortIO((struct IORequest *)audio_req[0]); - WaitIO((struct IORequest *)audio_req[0]); - - if(audio_req[1]) - { - D(bug("Break AGAIN req[1]...\n")); - AbortIO((struct IORequest *)audio_req[1]); - WaitIO((struct IORequest *)audio_req[1]); - } -// Double abort to be sure to break the dbuffering process. - - SDL_Delay(200); - - D(bug("Reqs breaked, closing device...\n")); - CloseDevice((struct IORequest *)audio_req[0]); - D(bug("Device closed, freeing memory...\n")); - myfree(audio_req[1]); - D(bug("Memory freed, deleting IOReq...\n")); - DeleteIORequest((struct IORequest *)audio_req[0]); - audio_req[0]=audio_req[1]=NULL; - } - - D(bug("Freeing mixbuf[0]...\n")); - if ( mixbuf[0] != NULL ) { - myfree(mixbuf[0]); -// SDL_FreeAudioMem(mixbuf[0]); - mixbuf[0] = NULL; - } - - D(bug("Freeing mixbuf[1]...\n")); - if ( mixbuf[1] != NULL ) { - myfree(mixbuf[1]); -// SDL_FreeAudioMem(mixbuf[1]); - mixbuf[1] = NULL; - } - - D(bug("Freeing audio_port...\n")); - - if ( audio_port != NULL ) { - DeleteMsgPort(audio_port); - audio_port = NULL; - } - D(bug("...done!\n")); -} - -static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) -{ - Uint16 test_format = SDL_FirstAudioFormat(spec->format); - int valid_datatype = 1; - - D(bug("AHI opening...\n")); - - /* Determine the audio parameters from the AudioSpec */ - while ((!valid_datatype) && (test_format)) { - valid_datatype = 1; - switch (test_format) { - case AUDIO_S8: - D(bug("AUDIO_S8...\n")); - spec->format = AUDIO_S8; - this->hidden->bytespersample = 1; - if (spec->channels < 2) - this->hidden->type = AHIST_M8S; - else - this->hidden->type = AHIST_S8S; - break; - - case AUDIO_S16MSB: - D(bug("AUDIO_S16MSB...\n")); - spec->format = AUDIO_S16MSB; - this->hidden->bytespersample = 2; - if (spec->channels < 2) - this->hidden->type = AHIST_M16S; - else - this->hidden->type = AHIST_S16S; - break; - - default: - valid_datatype = 0; - test_format = SDL_NextAudioFormat(); - break; - } - } - - if (!valid_datatype) { /* shouldn't happen, but just in case... */ - SDL_SetError("Unsupported audio format"); - return (-1); - } - - if (spec->channels > 2) { - spec->channels = 2; /* will convert at higher level. */ - } - - D(bug("Before CalculateAudioSpec\n")); - /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec(spec); - - D(bug("Before CreateMsgPort\n")); - - if(!(audio_port=CreateMsgPort())) - { - SDL_SetError("Unable to create a MsgPort"); - return -1; - } - - D(bug("Before CreateIORequest\n")); - - if(!(audio_req[0]=(struct AHIRequest *)CreateIORequest(audio_port,sizeof(struct AHIRequest)))) - { - SDL_SetError("Unable to create an AHIRequest"); - DeleteMsgPort(audio_port); - return -1; - } - - audio_req[0]->ahir_Version = 4; - - if(OpenDevice(AHINAME,0,(struct IORequest *)audio_req[0],NULL)) - { - SDL_SetError("Unable to open AHI device!\n"); - DeleteIORequest((struct IORequest *)audio_req[0]); - DeleteMsgPort(audio_port); - return -1; - } - - D(bug("AFTER opendevice\n")); - - /* Set output frequency and size */ - this->hidden->freq = spec->freq; - this->hidden->size = spec->size; - - D(bug("Before buffer allocation\n")); - - /* Allocate mixing buffer */ - mixbuf[0] = (Uint8 *)mymalloc(spec->size); - mixbuf[1] = (Uint8 *)mymalloc(spec->size); - - D(bug("Before audio_req allocation\n")); - - if(!(audio_req[1]=mymalloc(sizeof(struct AHIRequest)))) - { - SDL_OutOfMemory(); - return(-1); - } - - D(bug("Before audio_req memcpy\n")); - - SDL_memcpy(audio_req[1],audio_req[0],sizeof(struct AHIRequest)); - - if ( mixbuf[0] == NULL || mixbuf[1] == NULL ) { - SDL_OutOfMemory(); - return(-1); - } - - D(bug("Before mixbuf memset\n")); - - SDL_memset(mixbuf[0], spec->silence, spec->size); - SDL_memset(mixbuf[1], spec->silence, spec->size); - - current_buffer=0; - playing=0; - - 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)); - - /* We're ready to rock and roll. :-) */ - return(0); -}
--- a/src/audio/amigaos/SDL_ahiaudio.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_ahiaudio_h -#define _SDL_ahiaudio_h - -#include <exec/exec.h> -#include <dos/dos.h> -#ifdef __SASC -#include <proto/exec.h> -#else -#include <inline/exec.h> -#endif - -#include <devices/ahi.h> -#include "mydebug.h" - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -struct SDL_PrivateAudioData { - /* The handle for the audio device */ - struct AHIRequest *audio_req[2]; - struct MsgPort *audio_port; - Sint32 freq,type,bytespersample,size; - Uint8 *mixbuf[2]; /* The app mixing buffer */ - int current_buffer; - Uint32 playing; -}; - -/* Old variable names */ -#define audio_port (this->hidden->audio_port) -#define audio_req (this->hidden->audio_req) -#define mixbuf (this->hidden->mixbuf) -#define current_buffer (this->hidden->current_buffer) -#define playing (this->hidden->playing) - -#endif /* _SDL_ahiaudio_h */
--- a/src/joystick/amigaos/SDL_sysjoystick.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,233 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifdef SDL_JOYSTICK_AMIGA - -/* This is the system specific header for the SDL joystick API */ - -#include <libraries/lowlevel.h> -#if defined(__SASC) || defined(STORMC4_WOS) -#include <proto/exec.h> -#include <proto/lowlevel.h> -#include <proto/graphics.h> -#else -#include <inline/exec.h> -#include <inline/lowlevel.h> -#include <inline/graphics.h> -#endif -#include "mydebug.h" - -extern struct ExecBase *SysBase; -extern struct GfxBase *GfxBase; - -#include "SDL_joystick.h" -#include "../SDL_sysjoystick.h" -#include "../SDL_joystick_c.h" - -/* Function to scan the system for joysticks. - * This function should set SDL_numjoysticks to the number of available - * joysticks. Joystick 0 should be the system default joystick. - * It should return 0, or -1 on an unrecoverable fatal error. - */ - - -/* Amiga specific datas */ -struct Library *LowLevelBase=NULL; - -ULONG joybut[]= -{ - JPF_BUTTON_RED, - JPF_BUTTON_BLUE, - JPF_BUTTON_PLAY, - JPF_BUTTON_YELLOW, - JPF_BUTTON_GREEN, - JPF_BUTTON_FORWARD, - JPF_BUTTON_REVERSE, -}; - -struct joystick_hwdata -{ - ULONG joystate; -}; - -int SDL_SYS_JoystickInit(void) -{ - if(!LowLevelBase) - { - if(LowLevelBase=OpenLibrary("lowlevel.library",37)) - return 2; - } - else - return 2; - - D(bug("%ld joysticks available.\n",SDL_numjoysticks)); - - return 0; -} - -/* Function to get the device-dependent name of a joystick */ -const char *SDL_SYS_JoystickName(int index) -{ - if(index<2&&LowLevelBase) - { - switch(index) - { - case 0: - return "Port 1 Amiga Joystick/Joypad"; - case 1: - return "Port 2 Amiga Joystick/Joypad"; - } - } - - SDL_SetError("No joystick available with that index"); - return(NULL); -} - -/* Function to open a joystick for use. - The joystick to open is specified by the index field of the joystick. - This should fill the nbuttons and naxes fields of the joystick structure. - It returns 0, or -1 if there is an error. - */ - -int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) -{ - ULONG temp,i; - D(bug("Opening joystick %ld\n",joystick->index)); - - if(!(joystick->hwdata=SDL_malloc(sizeof(struct joystick_hwdata)))) - return -1; - -/* This loop is to check if the controller is a joypad */ - - for(i=0;i<20;i++) - { - temp=ReadJoyPort(joystick->index^1); // fix to invert amiga joyports - WaitTOF(); - } - - if((temp&JP_TYPE_MASK)==JP_TYPE_GAMECTLR) - joystick->nbuttons=7; - else - joystick->nbuttons=3; - - joystick->nhats=0; - joystick->nballs=0; - joystick->naxes=2; - joystick->hwdata->joystate=0L; - - return 0; -} - -/* Function to update the state of a joystick - called as a device poll. - * This function shouldn't update the joystick structure directly, - * but instead should call SDL_PrivateJoystick*() to deliver events - * and update joystick device state. - */ -void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) -{ - ULONG data; - int i; - - if(joystick->index<2) - { - data=ReadJoyPort(joystick->index); - - if(data&JP_DIRECTION_MASK) - { - if(data&JPF_JOY_DOWN) - { - if(!(joystick->hwdata->joystate&JPF_JOY_DOWN)) - SDL_PrivateJoystickAxis(joystick,0,127); - } - else if(data&JPF_JOY_UP) - { - if(!(joystick->hwdata->joystate&JPF_JOY_UP)) - SDL_PrivateJoystickAxis(joystick,0,-127); - } - else if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN)) - SDL_PrivateJoystickAxis(joystick,0,0); - - if(data&JPF_JOY_LEFT) - { - if(!(joystick->hwdata->joystate&JPF_JOY_LEFT)) - SDL_PrivateJoystickAxis(joystick,1,-127); - } - else if(data&JPF_JOY_RIGHT) - { - if(!(joystick->hwdata->joystate&JPF_JOY_RIGHT)) - SDL_PrivateJoystickAxis(joystick,1,127); - } - else if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT)) - SDL_PrivateJoystickAxis(joystick,1,0); - } - else if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT)) - { - SDL_PrivateJoystickAxis(joystick,1,0); - } - else if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN)) - { - SDL_PrivateJoystickAxis(joystick,0,0); - } - - for(i=0;i<joystick->nbuttons;i++) - { - if( (data&joybut[i]) ) - { - if(i==1) - data&=(~(joybut[2])); - - if(!(joystick->hwdata->joystate&joybut[i])) - SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED); - } - else if(joystick->hwdata->joystate&joybut[i]) - SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED); - } - - joystick->hwdata->joystate=data; - } - - return; -} - -/* Function to close a joystick after use */ -void SDL_SYS_JoystickClose(SDL_Joystick *joystick) -{ - if(joystick->hwdata) - SDL_free(joystick->hwdata); - return; -} - -/* Function to perform any system-specific joystick related cleanup */ - -void SDL_SYS_JoystickQuit(void) -{ - if(LowLevelBase) - { - CloseLibrary(LowLevelBase); - LowLevelBase=NULL; - SDL_numjoysticks=0; - } - return; -} - -#endif /* SDL_JOYSTICK_AMIGA */
--- a/src/thread/SDL_thread_c.h Sun Oct 29 03:44:25 2006 +0000 +++ b/src/thread/SDL_thread_c.h Sun Oct 29 03:58:27 2006 +0000 @@ -27,8 +27,6 @@ /* Need the definitions of SYS_ThreadHandle */ #if SDL_THREADS_DISABLED #include "generic/SDL_systhread_c.h" -#elif SDL_THREAD_AMIGA -#include "amigaos/SDL_systhread_c.h" #elif SDL_THREAD_BEOS #include "beos/SDL_systhread_c.h" #elif SDL_THREAD_DC
--- a/src/thread/amigaos/SDL_syssem.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* An implementation of semaphores using mutexes and condition variables */ - -#include "SDL_thread.h" -#include "SDL_systhread_c.h" - - -struct SDL_semaphore -{ - struct SignalSemaphore Sem; -}; - -#undef D - -#define D(x) - -SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) -{ - SDL_sem *sem; - - sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - - if ( ! sem ) { - SDL_OutOfMemory(); - return(0); - } - - D(bug("Creating semaphore %lx...\n",sem)); - - SDL_memset(sem,0,sizeof(*sem)); - - InitSemaphore(&sem->Sem); - - return(sem); -} - -void SDL_DestroySemaphore(SDL_sem *sem) -{ - D(bug("Destroying semaphore %lx...\n",sem)); - - if ( sem ) { -// Condizioni per liberare i task in attesa? - SDL_free(sem); - } -} - -int SDL_SemTryWait(SDL_sem *sem) -{ - if ( ! sem ) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - D(bug("TryWait semaphore...%lx\n",sem)); - - ObtainSemaphore(&sem->Sem); -// ReleaseSemaphore(&sem->Sem); - - return 1; -} - -int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) -{ - int retval; - - - if ( ! sem ) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - D(bug("WaitTimeout (%ld) semaphore...%lx\n",timeout,sem)); - - /* A timeout of 0 is an easy case */ - if ( timeout == 0 ) { - ObtainSemaphore(&sem->Sem); - return 1; - } - if(!(retval=AttemptSemaphore(&sem->Sem))) - { - SDL_Delay(timeout); - retval=AttemptSemaphore(&sem->Sem); - } - - if(retval==TRUE) - { -// ReleaseSemaphore(&sem->Sem); - retval=1; - } - - return retval; -} - -int SDL_SemWait(SDL_sem *sem) -{ - ObtainSemaphore(&sem->Sem); - return 0; -} - -Uint32 SDL_SemValue(SDL_sem *sem) -{ - Uint32 value; - - value = 0; - if ( sem ) { - #ifdef STORMC4_WOS - value = sem->Sem.ssppc_SS.ss_NestCount; - #else - value = sem->Sem.ss_NestCount; - #endif - } - return value; -} - -int SDL_SemPost(SDL_sem *sem) -{ - if ( ! sem ) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - D(bug("SemPost semaphore...%lx\n",sem)); - - ReleaseSemaphore(&sem->Sem); - return 0; -} -
--- a/src/thread/amigaos/SDL_systhread.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* BeOS thread management routines for SDL */ - -#include "SDL_mutex.h" -#include "SDL_thread.h" -#include "../SDL_thread_c.h" -#include "../SDL_systhread.h" -#include "mydebug.h" - -typedef struct { - int (*func)(void *); - void *data; - SDL_Thread *info; - struct Task *wait; -} thread_args; - -#ifndef MORPHOS - -#if defined(__SASC) && !defined(__PPC__) -__saveds __asm Uint32 RunThread(register __a0 char *args ) -#elif defined(__PPC__) -Uint32 RunThread(char *args) -#else -Uint32 __saveds RunThread(char *args __asm("a0") ) -#endif -{ - #ifdef STORMC4_WOS - thread_args *data=(thread_args *)args; - #else - thread_args *data=(thread_args *)atol(args); - #endif - - struct Task *Father; - - D(bug("Received data: %lx\n",data)); - Father=data->wait; - - SDL_RunThread(data); - - Signal(Father,SIGBREAKF_CTRL_F); - D(bug("Thread with data %lx ended\n",data)); - return(0); -} - -#else - -#include <emul/emulinterface.h> - -Uint32 RunTheThread(void) -{ - thread_args *data=(thread_args *)atol((char *)REG_A0); - struct Task *Father; - - D(bug("Received data: %lx\n",data)); - Father=data->wait; - - SDL_RunThread(data); - - Signal(Father,SIGBREAKF_CTRL_F); - D(bug("Thread with data %lx ended\n",data)); - return(0); -} - -struct EmulLibEntry RunThreadStruct= -{ - TRAP_LIB, - 0, - (ULONG)RunTheThread -}; - -void *RunThread=&RunThreadStruct; -#endif - - -int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) -{ - /* Create the thread and go! */ - char buffer[20]; - - D(bug("Sending %lx to the new thread...\n",args)); - - if(args) - SDL_snprintf(buffer, SDL_arraysize(buffer),"%ld",args); - - #ifdef STORMC4_WOS - thread->handle=CreateTaskPPCTags(TASKATTR_CODE, RunThread, - TASKATTR_NAME, "SDL subtask", - TASKATTR_STACKSIZE, 100000, - (args ? TASKATTR_R3 : TAG_IGNORE), args, - TASKATTR_INHERITR2, TRUE, - TAG_DONE); - #else - thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(), - NP_Name,(ULONG)"SDL subtask", - NP_CloseOutput, FALSE, - NP_StackSize,20000, - NP_Entry,(ULONG)RunThread, - args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer, - TAG_DONE); - #endif - - if(!thread->handle) - { - SDL_SetError("Not enough resources to create thread"); - return(-1); - } - - return(0); -} - -void SDL_SYS_SetupThread(void) -{ -} - -Uint32 SDL_ThreadID(void) -{ - return((Uint32)FindTask(NULL)); -} - -void SDL_SYS_WaitThread(SDL_Thread *thread) -{ - SetSignal(0L,SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C); - Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C); -} - -void SDL_SYS_KillThread(SDL_Thread *thread) -{ - Signal((struct Task *)thread->handle,SIGBREAKF_CTRL_C); -}
--- a/src/thread/amigaos/SDL_systhread_c.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include <exec/exec.h> -#include <dos/dos.h> -#include <dos/dostags.h> -#if defined (__SASC) || defined(STORMC4_WOS) -#include <proto/dos.h> -#include <proto/exec.h> -#else -#include <inline/dos.h> -#include <inline/exec.h> -#endif - -#include "mydebug.h" - -extern struct ExecBase *SysBase; -extern struct DosLibrary *DOSBase; - -#ifdef STORMC4_WOS -#include <proto/powerpc.h> - -/* use powerpc.library functions instead og exec */ -#define SYS_ThreadHandle struct TaskPPC * -#define Signal SignalPPC -#define Wait WaitPPC -#define Task TaskPPC -#define FindTask FindTaskPPC -#define SetSignal SetSignalPPC - -#define InitSemaphore InitSemaphorePPC -#define ObtainSemaphore ObtainSemaphorePPC -#define AttemptSemaphore AttemptSemaphorePPC -#define ReleaseSemaphore ReleaseSemaphorePPC -#define SignalSemaphore SignalSemaphorePPC - -#else - -#define SYS_ThreadHandle struct Task * -#endif /*STORMC4_WOS*/ -
--- a/src/thread/amigaos/SDL_thread.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,278 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* System independent thread management routines for SDL */ - -#include "SDL_mutex.h" -#include "SDL_thread.h" -#include "../SDL_thread_c.h" -#include "../SDL_systhread.h" - -#define ARRAY_CHUNKSIZE 32 -/* The array of threads currently active in the application - (except the main thread) - The manipulation of an array here is safer than using a linked list. -*/ -static int SDL_maxthreads = 0; -static int SDL_numthreads = 0; -static SDL_Thread **SDL_Threads = NULL; -static struct SignalSemaphore thread_lock; -int thread_lock_created = 0; - -int SDL_ThreadsInit(void) -{ - InitSemaphore(&thread_lock); - thread_lock_created=1; - return 0; -} - -/* This should never be called... - If this is called by SDL_Quit(), we don't know whether or not we should - clean up threads here. If any threads are still running after this call, - they will no longer have access to any per-thread data. - */ -void SDL_ThreadsQuit() -{ - thread_lock_created=0; -} - -/* Routines for manipulating the thread list */ -static void SDL_AddThread(SDL_Thread *thread) -{ - SDL_Thread **threads; - - /* WARNING: - If the very first threads are created simultaneously, then - there could be a race condition causing memory corruption. - In practice, this isn't a problem because by definition there - is only one thread running the first time this is called. - */ - if ( !thread_lock_created ) { - if ( SDL_ThreadsInit() < 0 ) { - return; - } - } - ObtainSemaphore(&thread_lock); - - /* Expand the list of threads, if necessary */ -#ifdef DEBUG_THREADS - printf("Adding thread (%d already - %d max)\n", - SDL_numthreads, SDL_maxthreads); -#endif - if ( SDL_numthreads == SDL_maxthreads ) { - threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)* - (sizeof *threads)); - if ( threads == NULL ) { - SDL_OutOfMemory(); - goto done; - } - SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads)); - SDL_maxthreads += ARRAY_CHUNKSIZE; - if ( SDL_Threads ) { - SDL_free(SDL_Threads); - } - SDL_Threads = threads; - } - SDL_Threads[SDL_numthreads++] = thread; -done: - ReleaseSemaphore(&thread_lock); -} - -static void SDL_DelThread(SDL_Thread *thread) -{ - int i; - - if ( thread_lock_created ) { - ObtainSemaphore(&thread_lock); - for ( i=0; i<SDL_numthreads; ++i ) { - if ( thread == SDL_Threads[i] ) { - break; - } - } - if ( i < SDL_numthreads ) { - --SDL_numthreads; - while ( i < SDL_numthreads ) { - SDL_Threads[i] = SDL_Threads[i+1]; - ++i; - } -#ifdef DEBUG_THREADS - printf("Deleting thread (%d left - %d max)\n", - SDL_numthreads, SDL_maxthreads); -#endif - } - ReleaseSemaphore(&thread_lock); - } -} - -/* The default (non-thread-safe) global error variable */ -static SDL_error SDL_global_error; - -/* Routine to get the thread-specific error variable */ -SDL_error *SDL_GetErrBuf(void) -{ - SDL_error *errbuf; - - errbuf = &SDL_global_error; - if ( SDL_Threads ) { - int i; - Uint32 this_thread; - - this_thread = SDL_ThreadID(); - ObtainSemaphore(&thread_lock); - for ( i=0; i<SDL_numthreads; ++i ) { - if ( this_thread == SDL_Threads[i]->threadid ) { - errbuf = &SDL_Threads[i]->errbuf; - break; - } - } - ReleaseSemaphore(&thread_lock); - } - return(errbuf); -} - - -/* Arguments and callback to setup and run the user thread function */ -typedef struct { - int (*func)(void *); - void *data; - SDL_Thread *info; - struct Task *wait; -} thread_args; - -void SDL_RunThread(void *data) -{ - thread_args *args; - int (*userfunc)(void *); - void *userdata; - int *statusloc; - - /* Perform any system-dependent setup - - this function cannot fail, and cannot use SDL_SetError() - */ - SDL_SYS_SetupThread(); - - /* Get the thread id */ - args = (thread_args *)data; - args->info->threadid = SDL_ThreadID(); - - /* Figure out what function to run */ - userfunc = args->func; - userdata = args->data; - statusloc = &args->info->status; - - /* Wake up the parent thread */ - Signal(args->wait,SIGBREAKF_CTRL_E); - - /* Run the function */ - *statusloc = userfunc(userdata); -} - -SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) -{ - SDL_Thread *thread; - thread_args *args; - int ret; - - /* Allocate memory for the thread info structure */ - thread = (SDL_Thread *)SDL_malloc(sizeof(*thread)); - if ( thread == NULL ) { - SDL_OutOfMemory(); - return(NULL); - } - SDL_memset(thread, 0, (sizeof *thread)); - thread->status = -1; - - /* Set up the arguments for the thread */ - args = (thread_args *)SDL_malloc(sizeof(*args)); - if ( args == NULL ) { - SDL_OutOfMemory(); - SDL_free(thread); - return(NULL); - } - args->func = fn; - args->data = data; - args->info = thread; - args->wait = FindTask(NULL); - if ( args->wait == NULL ) { - SDL_free(thread); - SDL_free(args); - SDL_OutOfMemory(); - return(NULL); - } - - /* Add the thread to the list of available threads */ - SDL_AddThread(thread); - - D(bug("Starting thread...\n")); - - /* Create the thread and go! */ - ret = SDL_SYS_CreateThread(thread, args); - if ( ret >= 0 ) { - D(bug("Waiting for thread CTRL_E...\n")); - /* Wait for the thread function to use arguments */ - Wait(SIGBREAKF_CTRL_E); - D(bug(" Arrived.")); - } else { - /* Oops, failed. Gotta free everything */ - SDL_DelThread(thread); - SDL_free(thread); - thread = NULL; - } - SDL_free(args); - - /* Everything is running now */ - return(thread); -} - -void SDL_WaitThread(SDL_Thread *thread, int *status) -{ - if ( thread ) { - SDL_SYS_WaitThread(thread); - if ( status ) { - *status = thread->status; - } - SDL_DelThread(thread); - SDL_free(thread); - } -} - -Uint32 SDL_GetThreadID(SDL_Thread *thread) -{ - Uint32 id; - - if ( thread ) { - id = thread->threadid; - } else { - id = SDL_ThreadID(); - } - return(id); -} - -void SDL_KillThread(SDL_Thread *thread) -{ - if ( thread ) { - SDL_SYS_KillThread(thread); - SDL_WaitThread(thread, NULL); - } -} -
--- a/src/timer/amigaos/SDL_systimer.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifdef SDL_TIMER_AMIGA - -#include <stdio.h> -#include <time.h> -#include <signal.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> -#include <exec/types.h> -#ifdef __SASC -#include <proto/dos.h> -#include <clib/graphics_protos.h> -#include <pragmas/graphics.h> -#include <clib/exec_protos.h> -#include <pragmas/exec.h> -#elif defined(STORMC4_WOS) -#include <proto/dos.h> -#include <proto/exec.h> -#include <proto/graphics.h> -#else -#include <inline/dos.h> -#include <inline/exec.h> -#include <inline/graphics.h> -#endif -#include "mydebug.h" - -extern struct DosLibrary *DOSBase; -extern struct ExecBase *SysBase; -static struct GfxBase *GfxBase; - -#include "SDL_timer.h" -#include "../SDL_timer_c.h" - -/* The first ticks value of the application */ - -#if !defined(__PPC__) || defined(STORMC4_WOS) || defined(MORPHOS) -static clock_t start; - -void SDL_StartTicks(void) -{ - /* Set first ticks value */ - start=clock(); -} - -Uint32 SDL_GetTicks (void) -{ - clock_t ticks; - - ticks=clock()-start; - -#ifdef __SASC -// CLOCKS_PER_SEC == 1000 ! - - return(ticks); -#else -// CLOCKS_PER_SEC != 1000 ! - - return ticks*(1000/CLOCKS_PER_SEC); -#endif -} - -void SDL_Delay (Uint32 ms) -{ -// Do a busy wait if time is less than 50ms - - if(ms<50) - { - clock_t to_wait=clock(); - -#ifndef __SASC - ms*=(CLOCKS_PER_SEC/1000); -#endif - to_wait+=ms; - - while(clock()<to_wait); - } - else - { - Delay(ms/20); - } -} - -#else - -ULONG MY_CLOCKS_PER_SEC; - -void PPC_TimerInit(void); -APTR MyTimer; - -ULONG start[2]; - -void SDL_StartTicks(void) -{ - /* Set first ticks value */ - if(!MyTimer) - PPC_TimerInit(); - - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,start); - start[1]>>=10; - start[1]|=((result[0]&0x3ff)<<22); - start[0]>>=10; -} - -Uint32 SDL_GetTicks (void) -{ - ULONG result[2]; - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result); - -// PPCAsr64p(result,10); -// Non va, la emulo: - - result[1]>>=10; - result[1]|=((result[0]&0x3ff)<<22); - -// Non mi interessa piu' result[0] - - return result[1]*1000/MY_CLOCKS_PER_SEC; -} - -void SDL_Delay (Uint32 ms) -{ -// Do a busy wait if time is less than 50ms - - if(ms<50) - { - ULONG to_wait[2],actual[2]; - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result); - actual[1]=0; - to_wait[1]+=ms*1000/MY_CLOCKS_PER_SEC; - - while(actual[1]<to_wait[1]) - { - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,actual); - } - } - else - { - Delay(ms/50); - } -} - -void PPC_TimerInit(void) -{ - struct TagItem tags[]= - { - PPCTIMERTAG_CPU,TRUE, - TAG_DONE,0 - }; - - - if(MyTimer=PPCCreateTimerObject(tags)) - { - ULONG result[2]; - - PPCGetTimerObject(MyTimer,PPCTIMERTAG_TICKSPERSEC,result); - D(bug("Timer inizializzato, TPS: %lu - %lu\n",result[0],result[1])); -// PPCAsr64p(result,10); - result[1]>>=10; - result[1]|=((result[0]&0x3ff)<<22); - result[0]>>=10; - - D(bug("Shiftato TPS: %lu - %lu\n",result[0],result[1])); - MY_CLOCKS_PER_SEC=result[1]; - - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result); - - D(bug("Current ticks: %lu - %lu\n",result[0],result[1])); - result[1]>>=10; - result[1]|=((result[0]&0x3ff)<<22); - result[0]>>=10; -// PPCAsr64p(result,10); - D(bug("Shiftato: %lu - %lu\n",result[0],result[1])); - } - else - { - D(bug("Errore nell'inizializzazione del timer!\n")); - } -} - -#endif - -#include "SDL_thread.h" - -/* Data to handle a single periodic alarm */ -static int timer_alive = 0; -static SDL_Thread *timer_thread = NULL; - -static int RunTimer(void *unused) -{ - D(bug("SYSTimer: Entering RunTimer loop...")); - - if(GfxBase==NULL) - GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",37); - - while ( timer_alive ) { - if ( SDL_timer_running ) { - SDL_ThreadedTimerCheck(); - } - if(GfxBase) - WaitTOF(); // Check the timer every fifth of seconds. Was SDL_Delay(1)->BusyWait! - else - Delay(1); - } - D(bug("SYSTimer: EXITING RunTimer loop...")); - return(0); -} - -/* This is only called if the event thread is not running */ -int SDL_SYS_TimerInit(void) -{ - D(bug("Creating thread for the timer (NOITIMER)...\n")); - - timer_alive = 1; - timer_thread = SDL_CreateThread(RunTimer, NULL); - if ( timer_thread == NULL ) - { - D(bug("Creazione del thread fallita...\n")); - - return(-1); - } - return(SDL_SetTimerThreaded(1)); -} - -void SDL_SYS_TimerQuit(void) -{ - timer_alive = 0; - if ( timer_thread ) { - SDL_WaitThread(timer_thread, NULL); - timer_thread = NULL; - } -} - -int SDL_SYS_StartTimer(void) -{ - SDL_SetError("Internal logic error: AmigaOS uses threaded timer"); - return(-1); -} - -void SDL_SYS_StopTimer(void) -{ - return; -} - -#endif /* SDL_TIMER_AMIGA */
--- a/src/video/SDL_video.c Sun Oct 29 03:44:25 2006 +0000 +++ b/src/video/SDL_video.c Sun Oct 29 03:58:27 2006 +0000 @@ -90,9 +90,6 @@ #if SDL_VIDEO_DRIVER_DRAWSPROCKET &DSp_bootstrap, #endif -#if SDL_VIDEO_DRIVER_CYBERGRAPHICS - &CGX_bootstrap, -#endif #if SDL_VIDEO_DRIVER_PHOTON &ph_bootstrap, #endif
--- a/src/video/cybergfx/SDL_amigaevents.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,535 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Handle the event stream, converting Amiga events into SDL events */ -#include "SDL.h" - -#include "SDL_syswm.h" -#include "../SDL_sysvideo.h" -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" -#include "SDL_cgxvideo.h" -#include "SDL_cgxmodes_c.h" -#include "SDL_cgximage_c.h" -#include "SDL_cgxwm_c.h" -#include "SDL_amigaevents_c.h" - - -/* The translation tables from an Amiga keysym to a SDL keysym */ -static SDLKey MISC_keymap[256]; -SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym); -struct IOStdReq *ConReq=NULL; -struct MsgPort *ConPort=NULL; - -/* Note: The X server buffers and accumulates mouse motion events, so - the motion event generated by the warp may not appear exactly as we - expect it to. We work around this (and improve performance) by only - warping the pointer when it reaches the edge, and then wait for it. -*/ -#define MOUSE_FUDGE_FACTOR 8 - -#if 0 - -static inline int amiga_WarpedMotion(_THIS, struct IntuiMessage *m) -{ - int w, h, i; - int deltax, deltay; - int posted; - - w = SDL_VideoSurface->w; - h = SDL_VideoSurface->h; - deltax = xevent->xmotion.x - mouse_last.x; - deltay = xevent->xmotion.y - mouse_last.y; -#ifdef DEBUG_MOTION - printf("Warped mouse motion: %d,%d\n", deltax, deltay); -#endif - mouse_last.x = xevent->xmotion.x; - mouse_last.y = xevent->xmotion.y; - posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay); - - if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) || - (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) || - (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || - (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) { - /* Get the events that have accumulated */ - while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) { - deltax = xevent->xmotion.x - mouse_last.x; - deltay = xevent->xmotion.y - mouse_last.y; -#ifdef DEBUG_MOTION - printf("Extra mouse motion: %d,%d\n", deltax, deltay); -#endif - mouse_last.x = xevent->xmotion.x; - mouse_last.y = xevent->xmotion.y; - posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay); - } - mouse_last.x = w/2; - mouse_last.y = h/2; - XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, - mouse_last.x, mouse_last.y); - for ( i=0; i<10; ++i ) { - XMaskEvent(SDL_Display, PointerMotionMask, xevent); - if ( (xevent->xmotion.x > - (mouse_last.x-MOUSE_FUDGE_FACTOR)) && - (xevent->xmotion.x < - (mouse_last.x+MOUSE_FUDGE_FACTOR)) && - (xevent->xmotion.y > - (mouse_last.y-MOUSE_FUDGE_FACTOR)) && - (xevent->xmotion.y < - (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) { - break; - } -#ifdef DEBUG_XEVENTS - printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y); -#endif - } -#ifdef DEBUG_XEVENTS - if ( i == 10 ) { - printf("Warning: didn't detect mouse warp motion\n"); - } -#endif - } - return(posted); -} - -#endif - -static int amiga_GetButton(int code) -{ - switch(code) - { - case IECODE_MBUTTON: - return SDL_BUTTON_MIDDLE; - case IECODE_RBUTTON: - return SDL_BUTTON_RIGHT; - default: - return SDL_BUTTON_LEFT; - } -} - -static int amiga_DispatchEvent(_THIS,struct IntuiMessage *msg) -{ - int class=msg->Class,code=msg->Code; - int posted; - - posted = 0; - switch (class) { - /* Gaining mouse coverage? */ - case IDCMP_ACTIVEWINDOW: - posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); - break; - - /* Losing mouse coverage? */ - case IDCMP_INACTIVEWINDOW: - posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); - break; -#if 0 - /* Gaining input focus? */ - case IDCMP_ACTIVEWINDOW: - posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); - - /* Queue entry into fullscreen mode */ - switch_waiting = 0x01 | SDL_FULLSCREEN; - switch_time = SDL_GetTicks() + 1500; - break; - - /* Losing input focus? */ - case IDCMP_INACTIVEWINDOW: - posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); - - /* Queue leaving fullscreen mode */ - switch_waiting = 0x01; - switch_time = SDL_GetTicks() + 200; - break; -#endif - /* Mouse motion? */ - case IDCMP_MOUSEMOVE: - if ( SDL_VideoSurface ) { - posted = SDL_PrivateMouseMotion(0, 0, - msg->MouseX-SDL_Window->BorderLeft, - msg->MouseY-SDL_Window->BorderTop); - } - break; - - /* Mouse button press? */ - case IDCMP_MOUSEBUTTONS: - - if(!(code&IECODE_UP_PREFIX)) - { - posted = SDL_PrivateMouseButton(SDL_PRESSED, - amiga_GetButton(code), 0, 0); - } - /* Mouse button release? */ - else - { - code&=~IECODE_UP_PREFIX; - posted = SDL_PrivateMouseButton(SDL_RELEASED, - amiga_GetButton(code), 0, 0); - } - break; - - case IDCMP_RAWKEY: - - /* Key press? */ - - if( !(code&IECODE_UP_PREFIX) ) - { - SDL_keysym keysym; - posted = SDL_PrivateKeyboard(SDL_PRESSED, - amiga_TranslateKey(code, &keysym)); - } - else - { - /* Key release? */ - - SDL_keysym keysym; - code&=~IECODE_UP_PREFIX; - - /* Check to see if this is a repeated key */ -/* if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) */ - - posted = SDL_PrivateKeyboard(SDL_RELEASED, - amiga_TranslateKey(code, &keysym)); - } - break; - /* Have we been iconified? */ -#if 0 - case UnmapNotify: { -#ifdef DEBUG_XEVENTS -printf("UnmapNotify!\n"); -#endif - posted=SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS); - } - break; - - /* Have we been restored? */ - - case MapNotify: { -#ifdef DEBUG_XEVENTS -printf("MapNotify!\n"); -#endif - - posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); - - if ( SDL_VideoSurface && - (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) - { - CGX_EnterFullScreen(this); - } else { - X11_GrabInputNoLock(this, this->input_grab); - } - if ( SDL_VideoSurface ) { - CGX_RefreshDisplay(this); - } - } - break; - case Expose: - if ( SDL_VideoSurface && (xevent.xexpose.count == 0) ) { - CGX_RefreshDisplay(this); - } - break; -#endif - - /* Have we been resized? */ - case IDCMP_NEWSIZE: - SDL_PrivateResize(SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight, - SDL_Window->Height-SDL_Window->BorderTop-SDL_Window->BorderBottom); - - break; - - /* Have we been requested to quit? */ - case IDCMP_CLOSEWINDOW: - posted = SDL_PrivateQuit(); - break; - - /* Do we need to refresh ourselves? */ - - default: { - /* Only post the event if we're watching for it */ - if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { - SDL_SysWMmsg wmmsg; - - SDL_VERSION(&wmmsg.version); -#if 0 - wmmsg.subsystem = SDL_SYSWM_CGX; - wmmsg.event.xevent = xevent; -#endif - posted = SDL_PrivateSysWMEvent(&wmmsg); - } - } - break; - } - ReplyMsg((struct Message *)msg); - - - return(posted); -} - -void amiga_PumpEvents(_THIS) -{ - int pending; - struct IntuiMessage *m; - - /* Keep processing pending events */ - pending = 0; - while ( m=(struct IntuiMessage *)GetMsg(SDL_Window->UserPort) ) { - amiga_DispatchEvent(this,m); - ++pending; - } -} - -void amiga_InitKeymap(void) -{ - int i; - - /* Map the miscellaneous keys */ - for ( i=0; i<SDL_arraysize(MISC_keymap); ++i ) - MISC_keymap[i] = SDLK_UNKNOWN; - - /* These X keysyms have 0xFF as the high byte */ - MISC_keymap[65] = SDLK_BACKSPACE; - MISC_keymap[66] = SDLK_TAB; - MISC_keymap[70] = SDLK_CLEAR; - MISC_keymap[70] = SDLK_DELETE; - MISC_keymap[68] = SDLK_RETURN; -// MISC_keymap[XK_Pause&0xFF] = SDLK_PAUSE; - MISC_keymap[69] = SDLK_ESCAPE; - MISC_keymap[70] = SDLK_DELETE; -/* - SDLK_SPACE = 32, - SDLK_MINUS = 45, - SDLK_LESS = 60, - SDLK_COMMA = 44, - SDLK_PERIOD = 46, - SDLK_0 = 48, - SDLK_1 = 49, - SDLK_2 = 50, - SDLK_3 = 51, - SDLK_4 = 52, - SDLK_5 = 53, - SDLK_6 = 54, - SDLK_7 = 55, - SDLK_8 = 56, - SDLK_9 = 57, - SDLK_BACKQUOTE = 96, - SDLK_BACKSLASH = 92, - SDLK_a = 97, - SDLK_b = 98, - SDLK_c = 99, - SDLK_d = 100, - SDLK_e = 101, - SDLK_f = 102, - SDLK_g = 103, - SDLK_h = 104, - SDLK_i = 105, - SDLK_j = 106, - SDLK_k = 107, - SDLK_l = 108, - SDLK_m = 109, - SDLK_n = 110, - SDLK_o = 111, - SDLK_p = 112, - SDLK_q = 113, - SDLK_r = 114, - SDLK_s = 115, - SDLK_t = 116, - SDLK_u = 117, - SDLK_v = 118, - SDLK_w = 119, - SDLK_x = 120, - SDLK_y = 121, - SDLK_z = 122, -*/ - MISC_keymap[15] = SDLK_KP0; /* Keypad 0-9 */ - MISC_keymap[29] = SDLK_KP1; - MISC_keymap[30] = SDLK_KP2; - MISC_keymap[31] = SDLK_KP3; - MISC_keymap[45] = SDLK_KP4; - MISC_keymap[46] = SDLK_KP5; - MISC_keymap[47] = SDLK_KP6; - MISC_keymap[61] = SDLK_KP7; - MISC_keymap[62] = SDLK_KP8; - MISC_keymap[63] = SDLK_KP9; - MISC_keymap[60] = SDLK_KP_PERIOD; - MISC_keymap[92] = SDLK_KP_DIVIDE; - MISC_keymap[93] = SDLK_KP_MULTIPLY; - MISC_keymap[74] = SDLK_KP_MINUS; - MISC_keymap[94] = SDLK_KP_PLUS; - MISC_keymap[67] = SDLK_KP_ENTER; -// MISC_keymap[XK_KP_Equal&0xFF] = SDLK_KP_EQUALS; - - MISC_keymap[76] = SDLK_UP; - MISC_keymap[77] = SDLK_DOWN; - MISC_keymap[78] = SDLK_RIGHT; - MISC_keymap[79] = SDLK_LEFT; -/* - MISC_keymap[XK_Insert&0xFF] = SDLK_INSERT; - MISC_keymap[XK_Home&0xFF] = SDLK_HOME; - MISC_keymap[XK_End&0xFF] = SDLK_END; -*/ -// Mappati sulle parentesi del taastierino - MISC_keymap[90] = SDLK_PAGEUP; - MISC_keymap[91] = SDLK_PAGEDOWN; - - MISC_keymap[80] = SDLK_F1; - MISC_keymap[81] = SDLK_F2; - MISC_keymap[82] = SDLK_F3; - MISC_keymap[83] = SDLK_F4; - MISC_keymap[84] = SDLK_F5; - MISC_keymap[85] = SDLK_F6; - MISC_keymap[86] = SDLK_F7; - MISC_keymap[87] = SDLK_F8; - MISC_keymap[88] = SDLK_F9; - MISC_keymap[89] = SDLK_F10; -// MISC_keymap[XK_F11&0xFF] = SDLK_F11; -// MISC_keymap[XK_F12&0xFF] = SDLK_F12; -// MISC_keymap[XK_F13&0xFF] = SDLK_F13; -// MISC_keymap[XK_F14&0xFF] = SDLK_F14; -// MISC_keymap[XK_F15&0xFF] = SDLK_F15; - -// MISC_keymap[XK_Num_Lock&0xFF] = SDLK_NUMLOCK; - MISC_keymap[98] = SDLK_CAPSLOCK; -// MISC_keymap[XK_Scroll_Lock&0xFF] = SDLK_SCROLLOCK; - MISC_keymap[97] = SDLK_RSHIFT; - MISC_keymap[96] = SDLK_LSHIFT; - MISC_keymap[99] = SDLK_LCTRL; - MISC_keymap[99] = SDLK_LCTRL; - MISC_keymap[101] = SDLK_RALT; - MISC_keymap[100] = SDLK_LALT; -// MISC_keymap[XK_Meta_R&0xFF] = SDLK_RMETA; -// MISC_keymap[XK_Meta_L&0xFF] = SDLK_LMETA; - MISC_keymap[103] = SDLK_LSUPER; /* Left "Windows" */ - MISC_keymap[102] = SDLK_RSUPER; /* Right "Windows */ - - MISC_keymap[95] = SDLK_HELP; -} - -SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym) -{ - #ifdef STORMC4_WOS - static struct Library *KeymapBase=NULL; /* Linking failed in WOS version if ConsoleDevice was used */ - #else - static struct Library *ConsoleDevice=NULL; - #endif - - /* Get the raw keyboard scancode */ - keysym->scancode = code; - keysym->sym = MISC_keymap[code]; - -#ifdef DEBUG_KEYS - fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode); -#endif - /* Get the translated SDL virtual keysym */ - if ( keysym->sym==SDLK_UNKNOWN ) - { - #ifdef STORMC4_WOS - if(!KeymapBase) - #else - if(!ConsoleDevice) - #endif - { - #ifdef STORMC4_WOS - KeymapBase=OpenLibrary("keymap.library", 0L); - #else - if(ConPort=CreateMsgPort()) - { - if(ConReq=CreateIORequest(ConPort,sizeof(struct IOStdReq))) - { - if(!OpenDevice("console.device",-1,(struct IORequest *)ConReq,0)) - ConsoleDevice=(struct Library *)ConReq->io_Device; - else - { - DeleteIORequest(ConReq); - ConReq=NULL; - } - } - else - { - DeleteMsgPort(ConPort); - ConPort=NULL; - } - } - #endif - } - - #ifdef STORMC4_WOS - if(KeymapBase) - #else - if(ConsoleDevice) - #endif - { - struct InputEvent event; - long actual; - char buffer[5]; - - event.ie_Qualifier=0; - event.ie_Class=IECLASS_RAWKEY; - event.ie_SubClass=0L; - event.ie_Code=code; - event.ie_X=event.ie_Y=0; - event.ie_EventAddress=NULL; - event.ie_NextEvent=NULL; - event.ie_Prev1DownCode=event.ie_Prev1DownQual=event.ie_Prev2DownCode=event.ie_Prev2DownQual=0; - - #ifdef STORMC4_WOS - if( (actual=MapRawKey(&event,buffer,5,NULL))>=0) - #else - if( (actual=RawKeyConvert(&event,buffer,5,NULL))>=0) - #endif - { - if(actual>1) - { - D(bug("Warning (%ld) character conversion!\n",actual)); - } - else if(actual==1) - { - keysym->sym=*buffer; - D(bug("Converted rawcode %ld to <%lc>\n",code,*buffer)); -// Bufferizzo x le successive chiamate! - MISC_keymap[code]=*buffer; - } - } - } - - } - keysym->mod = KMOD_NONE; - - /* If UNICODE is on, get the UNICODE value for the key */ - keysym->unicode = 0; - if ( SDL_TranslateUNICODE ) { -#if 0 - static XComposeStatus state; - /* Until we handle the IM protocol, use XLookupString() */ - unsigned char keybuf[32]; - if ( XLookupString(xkey, (char *)keybuf, sizeof(keybuf), - NULL, &state) ) { - keysym->unicode = keybuf[0]; - } -#endif - } - return(keysym); -} - -void amiga_InitOSKeymap(_THIS) -{ - amiga_InitKeymap(); -}
--- a/src/video/cybergfx/SDL_amigaevents_c.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_cgxvideo.h" - -/* Functions to be exported */ -extern void amiga_InitOSKeymap(_THIS); -extern void amiga_PumpEvents(_THIS); -
--- a/src/video/cybergfx/SDL_amigamouse.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_mouse.h" -#include "../../events/SDL_events_c.h" -#include "../SDL_cursor_c.h" -#include "SDL_amigamouse_c.h" - - -/* The implementation dependent data for the window manager cursor */ - -typedef void * WMCursor; - -void amiga_FreeWMCursor(_THIS, WMcursor *cursor) -{ -} - -WMcursor *amiga_CreateWMCursor(_THIS, - Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) -{ - return (WMcursor *)1; // Amiga has an Hardware cursor, so it's ok to return something unuseful but true -} - -int amiga_ShowWMCursor(_THIS, WMcursor *cursor) -{ - /* Don't do anything if the display is gone */ - if ( SDL_Display == NULL) { - return(0); - } - - /* Set the Amiga prefs cursor cursor, or blank if cursor is NULL */ - - if ( SDL_Window ) { - SDL_Lock_EventThread(); - if ( cursor == NULL ) { - if ( SDL_BlankCursor != NULL ) { -// Hide cursor HERE - SetPointer(SDL_Window,(UWORD *)SDL_BlankCursor,1,1,0,0); - } - } else { -// Show cursor - ClearPointer(SDL_Window); - } - SDL_Unlock_EventThread(); - } - return(1); -} - -void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y) -{ -/* FIXME: Not implemented */ -} - -/* Check to see if we need to enter or leave mouse relative mode */ -void amiga_CheckMouseMode(_THIS) -{ -}
--- a/src/video/cybergfx/SDL_amigamouse_c.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_cgxvideo.h" - -/* Functions to be exported */ -extern void amiga_FreeWMCursor(_THIS, WMcursor *cursor); -extern WMcursor *amiga_CreateWMCursor(_THIS, - Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); -extern int amiga_ShowWMCursor(_THIS, WMcursor *cursor); -extern void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y); -extern void amiga_CheckMouseMode(_THIS);
--- a/src/video/cybergfx/SDL_cgxaccel.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,262 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_endian.h" -#include "SDL_video.h" -#include "../SDL_sysvideo.h" -#include "../SDL_blit.h" -#include "SDL_cgxvideo.h" - -static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); - -// These are needed to avoid register troubles with gcc -O2! - -#if defined(__SASC) || defined(__PPC__) || defined(MORPHOS) -#define BMKBRP(a,b,c,d,e,f,g,h,i,j) BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j) -#define BBRP(a,b,c,d,e,f,g,h,i) BltBitMapRastPort(a,b,c,d,e,f,g,h,i) -#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) -#else -void BMKBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,APTR j) -{BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j);} - -void BBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i) -{BltBitMapRastPort(a,b,c,d,e,f,g,h,i);} - -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) -{BltBitMap(a,b,c,d,e,f,g,h,i,j,k);} -#endif - -int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key) -{ - if(surface->hwdata) - { - if(surface->hwdata->mask) - SDL_free(surface->hwdata->mask); - - if(surface->hwdata->mask=SDL_malloc(RASSIZE(surface->w,surface->h))) - { - Uint32 pitch,ok=0; - APTR lock; - - SDL_memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h)); - - 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)); - - if(lock=LockBitMapTags(surface->hwdata->bmap,LBMI_BASEADDRESS,(ULONG)&surface->pixels, - LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE)) - { - switch(surface->format->BytesPerPixel) - { - case 1: - { - unsigned char k=key; - register int i,j,t; - register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels; - - pitch-=surface->w; - - for(i=0;i<surface->h;i++) - { - for(t=128,j=0;j<surface->w;j++) - { - if(*map==k) - *dest&=~t; - - t>>=1; - - if(t==0) - { - dest++; - t=128; - } - map++; - } - map+=pitch; - } - } - break; - case 2: - { - Uint16 k=key,*mapw; - register int i,j,t; - register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels; - - for(i=surface->h;i;--i) - { - mapw=(Uint16 *)map; - - for(t=128,j=surface->w;j;--j) - { - if(*mapw==k) - *dest&=~t; - - t>>=1; - - if(t==0) - { - dest++; - t=128; - } - mapw++; - } - map+=pitch; - } - } - break; - case 4: - { - Uint32 *mapl; - register int i,j,t; - register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels; - - for(i=surface->h;i;--i) - { - mapl=(Uint32 *)map; - - for(t=128,j=surface->w;j;--j) - { - if(*mapl==key) - *dest&=~t; - - t>>=1; - - if(t==0) - { - dest++; - t=128; - } - mapl++; - } - map+=pitch; - } - - } - break; - default: - D(bug("Pixel mode non supported for color key...")); - SDL_free(surface->hwdata->mask); - surface->hwdata->mask=NULL; - ok=-1; - } - UnLockBitMap(lock); - D(bug("...Colorkey built!\n")); - return ok; - } - } - } - D(bug("HW colorkey not supported for this depth\n")); - - return -1; -} - -int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst) -{ -// Doesn't support yet alpha blitting - - if(src->hwdata&& !(src->flags & (SDL_SRCALPHA))) - { - D(bug("CheckHW blit... OK!\n")); - - if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) { - if ( CGX_SetHWColorKey(this, src, src->format->colorkey) < 0 ) { - src->flags &= ~SDL_HWACCEL; - return -1; - } - } - - src->flags|=SDL_HWACCEL; - src->map->hw_blit = CGX_HWAccelBlit; - return 1; - } - else - src->flags &= ~SDL_HWACCEL; - - D(bug("CheckHW blit... NO!\n")); - - return 0; -} - -static int temprp_init=0; -static struct RastPort temprp; - -static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect) -{ - struct SDL_VideoDevice *this=src->hwdata->videodata; - -// D(bug("Accel blit!\n")); - - if(src->flags&SDL_SRCCOLORKEY && src->hwdata->mask) - { - if(dst==SDL_VideoSurface) - { - BMKBRP(src->hwdata->bmap,srcrect->x,srcrect->y, - SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop, - srcrect->w,srcrect->h,0xc0,src->hwdata->mask); - } - else if(dst->hwdata) - { - if(!temprp_init) - { - InitRastPort(&temprp); - temprp_init=1; - } - temprp.BitMap=(struct BitMap *)dst->hwdata->bmap; - - BMKBRP(src->hwdata->bmap,srcrect->x,srcrect->y, - &temprp,dstrect->x,dstrect->y, - srcrect->w,srcrect->h,0xc0,src->hwdata->mask); - - } - } - else if(dst==SDL_VideoSurface) - { - BBRP(src->hwdata->bmap,srcrect->x,srcrect->y,SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,srcrect->w,srcrect->h,0xc0); - } - else if(dst->hwdata) - BBB(src->hwdata->bmap,srcrect->x,srcrect->y,dst->hwdata->bmap,dstrect->x,dstrect->y,srcrect->w,srcrect->h,0xc0,0xff,NULL); - - return 0; -} - -int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color) -{ - if(dst==SDL_VideoSurface) - { - FillPixelArray(SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,dstrect->w,dstrect->h,color); - } - else if(dst->hwdata) - { - if(!temprp_init) - { - InitRastPort(&temprp); - temprp_init=1; - } - - temprp.BitMap=(struct BitMap *)dst->hwdata->bmap; - - FillPixelArray(&temprp,dstrect->x,dstrect->y,dstrect->w,dstrect->h,color); - } - return 0; -}
--- a/src/video/cybergfx/SDL_cgxgl.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,212 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* StormMesa implementation of SDL OpenGL support */ - -#include "SDL_cgxgl_c.h" -#include "SDL_cgxvideo.h" - -#if SDL_VIDEO_OPENGL -AmigaMesaContext glcont=NULL; -#endif - -/* Init OpenGL */ -int CGX_GL_Init(_THIS) -{ -#if SDL_VIDEO_OPENGL - int i = 0; - struct TagItem attributes [ 14 ]; /* 14 should be more than enough :) */ - struct Window *win = (struct Window *)SDL_Window; - - // default config. Always used... - attributes[i].ti_Tag = AMA_Window; attributes[i++].ti_Data = (unsigned long)win; - attributes[i].ti_Tag = AMA_Left; attributes[i++].ti_Data = 0; - attributes[i].ti_Tag = AMA_Bottom; attributes[i++].ti_Data = 0; - attributes[i].ti_Tag = AMA_Width; attributes[i++].ti_Data = win->Width-win->BorderLeft-win->BorderRight; - attributes[i].ti_Tag = AMA_Height; attributes[i++].ti_Data = win->Height-win->BorderBottom-win->BorderTop; - attributes[i].ti_Tag = AMA_DirectRender; attributes[i++].ti_Data = GL_TRUE; - - // double buffer ? - attributes[i].ti_Tag = AMA_DoubleBuf; - if ( this->gl_config.double_buffer ) { - attributes[i++].ti_Data = GL_TRUE; - } - else { - attributes[i++].ti_Data = GL_FALSE; - } - // RGB(A) Mode ? - attributes[i].ti_Tag = AMA_RGBMode; - if ( this->gl_config.red_size != 0 && - this->gl_config.blue_size != 0 && - this->gl_config.green_size != 0 ) { - attributes[i++].ti_Data = GL_TRUE; - } - else { - attributes[i++].ti_Data = GL_FALSE; - } - // no depth buffer ? - if ( this->gl_config.depth_size == 0 ) { - attributes[i].ti_Tag = AMA_NoDepth; - attributes[i++].ti_Data = GL_TRUE; - } - // no stencil buffer ? - if ( this->gl_config.stencil_size == 0 ) { - attributes[i].ti_Tag = AMA_NoStencil; - attributes[i++].ti_Data = GL_TRUE; - } - // no accum buffer ? - if ( this->gl_config.accum_red_size != 0 && - this->gl_config.accum_blue_size != 0 && - this->gl_config.accum_green_size != 0 ) { - attributes[i].ti_Tag = AMA_NoAccum; - attributes[i++].ti_Data = GL_TRUE; - } - // done... - attributes[i].ti_Tag = TAG_DONE; - - glcont = AmigaMesaCreateContext(attributes); - if ( glcont == NULL ) { - SDL_SetError("Couldn't create OpenGL context"); - return(-1); - } - this->gl_data->gl_active = 1; - this->gl_config.driver_loaded = 1; - - return(0); -#else - SDL_SetError("OpenGL support not configured"); - return(-1); -#endif -} - -/* Quit OpenGL */ -void CGX_GL_Quit(_THIS) -{ -#if SDL_VIDEO_OPENGL - if ( glcont != NULL ) { - AmigaMesaDestroyContext(glcont); - glcont = NULL; - this->gl_data->gl_active = 0; - this->gl_config.driver_loaded = 0; - } -#endif -} - -/* Attach context to another window */ -int CGX_GL_Update(_THIS) -{ -#if SDL_VIDEO_OPENGL - struct TagItem tags[2]; - struct Window *win = (struct Window*)SDL_Window; - if(glcont == NULL) { - return -1; //should never happen - } - tags[0].ti_Tag = AMA_Window; - tags[0].ti_Data = (unsigned long)win; - tags[1].ti_Tag = TAG_DONE; - AmigaMesaSetRast(glcont, tags); - - return 0; -#else - SDL_SetError("OpenGL support not configured"); - return -1; -#endif -} - -#if SDL_VIDEO_OPENGL - -/* Make the current context active */ -int CGX_GL_MakeCurrent(_THIS) -{ - if(glcont == NULL) - return -1; - - AmigaMesaMakeCurrent(glcont, glcont->buffer); - return 0; -} - -void CGX_GL_SwapBuffers(_THIS) -{ - AmigaMesaSwapBuffers(glcont); -} - -int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) { - GLenum mesa_attrib; - - switch(attrib) { - case SDL_GL_RED_SIZE: - mesa_attrib = GL_RED_BITS; - break; - case SDL_GL_GREEN_SIZE: - mesa_attrib = GL_GREEN_BITS; - break; - case SDL_GL_BLUE_SIZE: - mesa_attrib = GL_BLUE_BITS; - break; - case SDL_GL_ALPHA_SIZE: - mesa_attrib = GL_ALPHA_BITS; - break; - case SDL_GL_DOUBLEBUFFER: - mesa_attrib = GL_DOUBLEBUFFER; - break; - case SDL_GL_DEPTH_SIZE: - mesa_attrib = GL_DEPTH_BITS; - break; - case SDL_GL_STENCIL_SIZE: - mesa_attrib = GL_STENCIL_BITS; - break; - case SDL_GL_ACCUM_RED_SIZE: - mesa_attrib = GL_ACCUM_RED_BITS; - break; - case SDL_GL_ACCUM_GREEN_SIZE: - mesa_attrib = GL_ACCUM_GREEN_BITS; - break; - case SDL_GL_ACCUM_BLUE_SIZE: - mesa_attrib = GL_ACCUM_BLUE_BITS; - break; - case SDL_GL_ACCUM_ALPHA_SIZE: - mesa_attrib = GL_ACCUM_ALPHA_BITS; - break; - default : - return -1; - } - - AmigaMesaGetConfig(glcont->visual, mesa_attrib, value); - return 0; -} - -void *CGX_GL_GetProcAddress(_THIS, const char *proc) { - void *func = NULL; - func = AmiGetGLProc(proc); - return func; -} - -int CGX_GL_LoadLibrary(_THIS, const char *path) { - /* Library is always open */ - this->gl_config.driver_loaded = 1; - - return 0; -} - -#endif /* SDL_VIDEO_OPENGL */ -
--- a/src/video/cybergfx/SDL_cgxgl_c.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* StormMesa implementation of SDL OpenGL support */ - -#include "../SDL_sysvideo.h" - -#define _THIS SDL_VideoDevice *_this - -#if SDL_VIDEO_OPENGL -#include <GL/Amigamesa.h> -extern void *AmiGetGLProc(const char *proc); -#endif /* SDL_VIDEO_OPENGL */ - -struct SDL_PrivateGLData { - int gl_active; -}; - -/* OpenGL functions */ -extern int CGX_GL_Init(_THIS); -extern void CGX_GL_Quit(_THIS); -extern int CGX_GL_Update(_THIS); -#if SDL_VIDEO_OPENGL -extern int CGX_GL_MakeCurrent(_THIS); -extern int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); -extern void CGX_GL_SwapBuffers(_THIS); -extern void *CGX_GL_GetProcAddress(_THIS, const char *proc); -extern int CGX_GL_LoadLibrary(_THIS, const char *path); -#endif - -#undef _THIS
--- a/src/video/cybergfx/SDL_cgximage.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,906 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_endian.h" -#include "SDL_cgximage_c.h" - -#ifdef HAVE_KSTAT -#include <kstat.h> -#endif - -#ifdef USE_CGX_WRITELUTPIXEL -#if defined(__SASC) || defined(__PPC__) - #define WLUT WriteLUTPixelArray -#else -void WLUT(APTR a,UWORD b,UWORD c,UWORD d,struct RastPort *e,APTR f,UWORD g,UWORD h,UWORD i,UWORD l,UBYTE m) -{ WriteLUTPixelArray(a,b,c,d,e,f,g,h,i,l,m); } -#endif - -#endif - -/* Various screen update functions available */ -static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); -static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect *rects); - -BOOL SafeDisp=TRUE,SafeChange=TRUE; -struct MsgPort *safeport=NULL,*dispport=NULL; -ULONG safe_sigbit,disp_sigbit; -int use_picasso96=1; - -int CGX_SetupImage(_THIS, SDL_Surface *screen) -{ - SDL_Ximage=NULL; - - if(screen->flags&SDL_HWSURFACE) { - ULONG pitch; - - if(!screen->hwdata) { - if(!(screen->hwdata=SDL_malloc(sizeof(struct private_hwdata)))) - return -1; - - D(bug("Creating system accel struct\n")); - } - screen->hwdata->lock=NULL; - screen->hwdata->allocated=0; - screen->hwdata->mask=NULL; - screen->hwdata->bmap=SDL_RastPort->BitMap; - screen->hwdata->videodata=this; - - if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap, - LBMI_BASEADDRESS,(ULONG)&screen->pixels, - LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) { - SDL_free(screen->hwdata); - screen->hwdata=NULL; - return -1; - } - else { - UnLockBitMap(screen->hwdata->lock); - screen->hwdata->lock=NULL; - } - - screen->pitch=pitch; - - this->UpdateRects = CGX_FakeUpdate; - - D(bug("Accel video image configured (%lx, pitch %ld).\n",screen->pixels,screen->pitch)); - return 0; - } - - screen->pixels = SDL_malloc(screen->h*screen->pitch); - - if ( screen->pixels == NULL ) { - SDL_OutOfMemory(); - return(-1); - } - - SDL_Ximage=screen->pixels; - - if ( SDL_Ximage == NULL ) { - SDL_SetError("Couldn't create XImage"); - return(-1); - } - - this->UpdateRects = CGX_NormalUpdate; - - return(0); -} - -void CGX_DestroyImage(_THIS, SDL_Surface *screen) -{ - if ( SDL_Ximage ) { - SDL_free(SDL_Ximage); - SDL_Ximage = NULL; - } - if ( screen ) { - screen->pixels = NULL; - - if(screen->hwdata) { - SDL_free(screen->hwdata); - screen->hwdata=NULL; - } - } -} - -/* This is a hack to see whether this system has more than 1 CPU */ -static int num_CPU(void) -{ - return 1; -} - -int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) -{ - int retval; - - D(bug("Calling ResizeImage()\n")); - - CGX_DestroyImage(this, screen); - - if ( flags & SDL_OPENGL ) { /* No image when using GL */ - retval = 0; - } else { - retval = CGX_SetupImage(this, screen); - /* We support asynchronous blitting on the display */ - if ( flags & SDL_ASYNCBLIT ) { - if ( num_CPU() > 1 ) { - screen->flags |= SDL_ASYNCBLIT; - } - } - } - return(retval); -} - -int CGX_AllocHWSurface(_THIS, SDL_Surface *surface) -{ - D(bug("Alloc HW surface...%ld x %ld x %ld!\n",surface->w,surface->h,this->hidden->depth)); - - if(surface==SDL_VideoSurface) - { - D(bug("Allocation skipped, it's system one!\n")); - return 0; - } - - if(!surface->hwdata) - { - if(!(surface->hwdata=SDL_malloc(sizeof(struct private_hwdata)))) - return -1; - } - - surface->hwdata->mask=NULL; - surface->hwdata->lock=NULL; - surface->hwdata->videodata=this; - surface->hwdata->allocated=0; - - if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap)) - { - surface->hwdata->allocated=1; - surface->flags|=SDL_HWSURFACE; - D(bug("...OK\n")); - return 0; - } - else - { - SDL_free(surface->hwdata); - surface->hwdata=NULL; - } - - return(-1); -} -void CGX_FreeHWSurface(_THIS, SDL_Surface *surface) -{ - if(surface && surface!=SDL_VideoSurface && surface->hwdata) - { - D(bug("Free hw surface.\n")); - - if(surface->hwdata->mask) - SDL_free(surface->hwdata->mask); - - if(surface->hwdata->bmap&&surface->hwdata->allocated) - FreeBitMap(surface->hwdata->bmap); - - SDL_free(surface->hwdata); - surface->hwdata=NULL; - surface->pixels=NULL; - D(bug("end of free hw surface\n")); - } - return; -} - -int CGX_LockHWSurface(_THIS, SDL_Surface *surface) -{ - if (surface->hwdata) - { -// D(bug("Locking a bitmap...\n")); - if(!surface->hwdata->lock) - { - Uint32 pitch; - - if(!(surface->hwdata->lock=LockBitMapTags(surface->hwdata->bmap, - LBMI_BASEADDRESS,(ULONG)&surface->pixels, - LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) - return -1; - -// surface->pitch e' a 16bit! - - surface->pitch=pitch; - - if(!currently_fullscreen&&surface==SDL_VideoSurface) - surface->pixels=((char *)surface->pixels)+(surface->pitch*(SDL_Window->BorderTop+SDL_Window->TopEdge)+ - surface->format->BytesPerPixel*(SDL_Window->BorderLeft+SDL_Window->LeftEdge)); - } - D(else bug("Already locked!!!\n")); - } - return(0); -} - -void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface) -{ - if(surface->hwdata && surface->hwdata->lock) - { - UnLockBitMap(surface->hwdata->lock); - surface->hwdata->lock=NULL; -// surface->pixels=NULL; - } -} - -int CGX_FlipHWSurface(_THIS, SDL_Surface *surface) -{ - static int current=0; - - if(this->hidden->dbuffer) - { - if(!SafeChange) - { - Wait(disp_sigbit); -// Non faccio nulla, vuoto solo la porta - while(GetMsg(dispport)!=NULL) - ; - SafeChange=TRUE; - } - - if(ChangeScreenBuffer(SDL_Display,this->hidden->SB[current^1])) - { - surface->hwdata->bmap=SDL_RastPort->BitMap=this->hidden->SB[current]->sb_BitMap; - SafeChange=FALSE; - SafeDisp=FALSE; - current^=1; - } - - if(!SafeDisp) - { - Wait(safe_sigbit); - while(GetMsg(safeport)!=NULL) - ; - SafeDisp=TRUE; - } - - } - return(0); -} - -/* Byte-swap the pixels in the display image */ -static void CGX_SwapAllPixels(SDL_Surface *screen) -{ - int x, y; - - switch (screen->format->BytesPerPixel) { - case 2: { - Uint16 *spot; - for ( y=0; y<screen->h; ++y ) { - spot = (Uint16 *) ((Uint8 *)screen->pixels + - y * screen->pitch); - for ( x=0; x<screen->w; ++x, ++spot ) { - *spot = SDL_Swap16(*spot); - } - } - } - break; - - case 4: { - Uint32 *spot; - for ( y=0; y<screen->h; ++y ) { - spot = (Uint32 *) ((Uint8 *)screen->pixels + - y * screen->pitch); - for ( x=0; x<screen->w; ++x, ++spot ) { - *spot = SDL_Swap32(*spot); - } - } - } - break; - - default: - /* should never get here */ - break; - } -} -static void CGX_SwapPixels(SDL_Surface *screen, int numrects, SDL_Rect *rects) -{ - int i; - int x, minx, maxx; - int y, miny, maxy; - - switch (screen->format->BytesPerPixel) { - case 2: { - Uint16 *spot; - for ( i=0; i<numrects; ++i ) { - minx = rects[i].x; - maxx = rects[i].x+rects[i].w; - miny = rects[i].y; - maxy = rects[i].y+rects[i].h; - for ( y=miny; y<maxy; ++y ) { - spot = (Uint16 *) ((Uint8 *)screen->pixels + - y * screen->pitch + minx * 2); - for ( x=minx; x<maxx; ++x, ++spot ) { - *spot = SDL_Swap16(*spot); - } - } - } - } - break; - - case 4: { - Uint32 *spot; - for ( i=0; i<numrects; ++i ) { - minx = rects[i].x; - maxx = rects[i].x+rects[i].w; - miny = rects[i].y; - maxy = rects[i].y+rects[i].h; - for ( y=miny; y<maxy; ++y ) { - spot = (Uint32 *) ((Uint8 *)screen->pixels + - y * screen->pitch + minx * 4); - for ( x=minx; x<maxx; ++x, ++spot ) { - *spot = SDL_Swap32(*spot); - } - } - } - } - break; - - default: - /* should never get here */ - break; - } -} - -#ifdef __SASC - -#define USE_WPA WritePixelArray -#else - -void USE_WPA(char *a,int b,int c,int d, struct RastPort *e,int f,int g, int h, int i, Uint32 l) -{ - WritePixelArray(a,b,c,d,e,f,g,h,i,l); -} - -#endif - -static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect *rects) -{ -} - -static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) -{ - int i,format,customroutine=0; -#ifndef USE_CGX_WRITELUTPIXEL - int bpp; -#endif - if(this->hidden->same_format && !use_picasso96) - { - format=RECTFMT_RAW; - } - else switch(this->screen->format->BytesPerPixel) - { - case 4: - format=RECTFMT_RGBA; - break; - case 3: - format=RECTFMT_RGB; - break; - case 2: - customroutine=1; - break; - case 1: -// D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth)); - if(this->hidden->depth>8) - { -#ifndef USE_CGX_WRITELUTPIXEL - if(this->hidden->depth>32) - customroutine=4; - else if(this->hidden->depth>16) - { - bpp=this->hidden->BytesPerPixel; // That one is the only one that needs bpp - customroutine=2; // The slow one! - } - else - customroutine=3; -#else - - customroutine=2; -#endif - -// format=RECTFMT_LUT8; Vecchia funzione x usare la WritePixelArray. - } - else - customroutine=1; - break; - default: - D(bug("Unable to blit this surface!\n")); - return; - } - - /* Check for endian-swapped X server, swap if necessary (VERY slow!) */ - if ( swap_pixels && - ((this->screen->format->BytesPerPixel%2) == 0) ) { - D(bug("Software Swapping! SLOOOW!\n")); - CGX_SwapPixels(this->screen, numrects, rects); - for ( i=0; i<numrects; ++i ) { - if ( ! rects[i].w ) { /* Clipped? */ - continue; - } - USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch, - SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y, - rects[i].w,rects[i].h,format); - } - CGX_SwapPixels(this->screen, numrects, rects); - } - else if (customroutine==2) - { -#ifdef USE_CGX_WRITELUTPIXEL - for ( i=0; i<numrects; ++i ) { - if ( ! rects[i].w ) { /* Clipped? */ - continue; - } - - WLUT(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch, - SDL_RastPort,SDL_XPixels,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y, - rects[i].w,rects[i].h,CTABFMT_XRGB8); - } -#else - unsigned char *bm_address; - Uint32 destpitch; - APTR handle; - - if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address, - LBMI_BYTESPERROW,&destpitch,TAG_DONE)) - { - int srcwidth; - unsigned char *destbase; - register int j,k,t; - register unsigned char *mask,*dst; - register unsigned char *src,*dest; - -// Aggiungo il bordo della finestra se sono fullscreen. - if(currently_fullscreen) - destbase=bm_address; - else - destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - - for ( i=0; i<numrects; ++i ) - { - srcwidth=rects[i].w; - - if ( !srcwidth ) { /* Clipped? */ - continue; - } - - dest=destbase+rects[i].x*this->hidden->BytesPerPixel; - dest+=(rects[i].y*destpitch); - src=((char *)(this->screen->pixels))+rects[i].x; - src+=(rects[i].y*this->screen->pitch); - - for(j=rects[i].h;j;--j) - { - dst=dest; -// SLOW routine, used for 8->24 bit mapping - for(k=0;k<srcwidth;k++) - { - mask=(unsigned char *)(&SDL_XPixels[src[k]]); - for(t=0;t<bpp;t++) - { - dst[t]=mask[t]; - } - dst+=bpp; - } - src+=this->screen->pitch; - dest+=destpitch; - } - } - UnLockBitMap(handle); - } - } - else if (customroutine==3) - { - unsigned char *bm_address; - Uint32 destpitch; - APTR handle; - - if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address, - LBMI_BYTESPERROW,&destpitch,TAG_DONE)) - { - int srcwidth; - unsigned char *destbase; - register int j,k; - register unsigned char *src,*dest; - register Uint16 *destl,*srcl; - - if(currently_fullscreen) - destbase=bm_address; - else - destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - - for ( i=0; i<numrects; ++i ) - { - srcwidth=rects[i].w; - - if ( !srcwidth ) { /* Clipped? */ - continue; - } - - dest=destbase+rects[i].x*this->hidden->BytesPerPixel; - dest+=(rects[i].y*destpitch); - src=((char *)(this->screen->pixels))+rects[i].x; - src+=(rects[i].y*this->screen->pitch); - -// This is the fast, well not too slow, remapping code for 16bit displays - - for(j=rects[i].h;j;--j) - { - destl=(Uint16 *)dest; - - for(k=0;k<srcwidth;k++) - { - srcl=(Uint16 *)&SDL_XPixels[src[k]]; - *destl=*srcl; - destl++; - } - src+=this->screen->pitch; - dest+=destpitch; - } - } - UnLockBitMap(handle); - } - } - else if (customroutine==4) - { - unsigned char *bm_address; - Uint32 destpitch; - APTR handle; - - if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address, - LBMI_BYTESPERROW,&destpitch,TAG_DONE)) - { - int srcwidth; - unsigned char *destbase; - register int j,k; - register unsigned char *src,*dest; - register Uint32 *destl,*srcl; - - if(currently_fullscreen) - destbase=bm_address; - else - destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - - for ( i=0; i<numrects; ++i ) - { - srcwidth=rects[i].w; - - if ( !srcwidth ) { /* Clipped? */ - continue; - } - - dest=destbase+rects[i].x*this->hidden->BytesPerPixel; - dest+=(rects[i].y*destpitch); - src=((char *)(this->screen->pixels))+rects[i].x; - src+=(rects[i].y*this->screen->pitch); - -// This is the fast, well not too slow, remapping code for 32bit displays - - for(j=rects[i].h;j;--j) - { - destl=(Uint32 *)dest; - - for(k=0;k<srcwidth;k++) - { - srcl=(Uint32 *)&SDL_XPixels[src[k]]; - *destl=*srcl; - destl++; - } - src+=this->screen->pitch; - dest+=destpitch; - } - } - UnLockBitMap(handle); - } -#endif - } - else if(customroutine) - { - unsigned char *bm_address; - Uint32 destpitch; - APTR handle; - -// D(bug("Using customroutine!\n")); - - if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address, - LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) - { - unsigned char *destbase; - register int j,srcwidth; - register unsigned char *src,*dest; - -// Aggiungo il bordo della finestra se sono fullscreen. - if(currently_fullscreen) - destbase=bm_address; - else - destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->screen->format->BytesPerPixel; - - for ( i=0; i<numrects; ++i ) - { - srcwidth=rects[i].w; - - if ( !srcwidth ) { /* Clipped? */ - continue; - } - - dest=destbase+rects[i].x*this->screen->format->BytesPerPixel; - dest+=(rects[i].y*destpitch); - src=((char *)(this->screen->pixels))+rects[i].x*this->screen->format->BytesPerPixel; - src+=(rects[i].y*this->screen->pitch); - - srcwidth*=this->screen->format->BytesPerPixel; - -// D(bug("Rects: %ld,%ld %ld,%ld Src:%lx Dest:%lx\n",rects[i].x,rects[i].y,rects[i].w,rects[i].h,src,dest)); - - for(j=rects[i].h;j;--j) - { - SDL_memcpy(dest,src,srcwidth); - src+=this->screen->pitch; - dest+=destpitch; - } - } - UnLockBitMap(handle); -// D(bug("Rectblit addr: %lx pitch: %ld rects:%ld srcptr: %lx srcpitch: %ld\n",bm_address,destpitch,numrects,this->screen->pixels,this->screen->pitch)); - } - } - else - { - for ( i=0; i<numrects; ++i ) { - if ( ! rects[i].w ) { /* Clipped? */ - continue; - } - USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch, - SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y, - rects[i].w,rects[i].h,format); - } - } -} - -void CGX_RefreshDisplay(_THIS) -{ - int format,customroutine=0; -#ifndef USE_CGX_WRITELUTPIXEL - int bpp; -#endif - /* Don't refresh a display that doesn't have an image (like GL) */ - if ( ! SDL_Ximage ) { - return; - } - - if(this->hidden->same_format && !use_picasso96) - { - format=RECTFMT_RAW; - } - else switch(this->screen->format->BytesPerPixel) - { - case 4: - format=RECTFMT_RGBA; - break; - case 3: - format=RECTFMT_RGB; - break; - case 2: - customroutine=1; - break; - case 1: -// D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth)); - if(this->hidden->depth>8) - { -#ifndef USE_CGX_WRITELUTPIXEL - if(this->hidden->depth>32) - customroutine=4; - else if(this->hidden->depth>16) - { - bpp=this->hidden->BytesPerPixel; // That one is the only one that needs bpp - customroutine=2; // The slow one! - } - else - customroutine=3; -#else - - customroutine=2; -#endif -// format=RECTFMT_LUT8; - } - else - customroutine=1; - break; - - } - - /* Check for endian-swapped X server, swap if necessary */ - if ( swap_pixels && - ((this->screen->format->BytesPerPixel%2) == 0) ) { - CGX_SwapAllPixels(this->screen); - USE_WPA(this->screen->pixels,0,0,this->screen->pitch, - SDL_RastPort,SDL_Window->BorderLeft,SDL_Window->BorderTop, - this->screen->w,this->screen->h,format); - CGX_SwapAllPixels(this->screen); - } - else if (customroutine==2) - { -#ifdef USE_CGX_WRITELUTPIXEL - WLUT(this->screen->pixels,0,0,this->screen->pitch, - SDL_RastPort,SDL_XPixels,SDL_Window->BorderLeft,SDL_Window->BorderTop, - this->screen->w,this->screen->h,CTABFMT_XRGB8); -#else - unsigned char *bm_address; - Uint32 destpitch; - APTR handle; - - if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address, - LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) - { - register int j,k,t; - register unsigned char *mask,*dst; - register unsigned char *src,*dest; - -// Aggiungo il bordo della finestra se sono fullscreen. - if(!currently_fullscreen) - dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - else - dest=bm_address; - - src=this->screen->pixels; - - for(j=this->screen->h;j;--j) - { - dst=dest; -// SLOW routine, used for 8->24 bit mapping - for(k=0;k<this->screen->w;k++) - { - mask=(unsigned char *)(&SDL_XPixels[src[k]]); - for(t=0;t<bpp;t++) - { - dst[t]=mask[t]; - } - dst+=bpp; - } - src+=this->screen->pitch; - dest+=destpitch; - } - UnLockBitMap(handle); - } - } - else if (customroutine==3) - { - unsigned char *bm_address; - Uint32 destpitch; - APTR handle; - - if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address, - LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) - { - register int j,k; - register unsigned char *src,*dest; - register Uint16 *destl,*srcl; - - if(!currently_fullscreen) - dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - else - dest=bm_address; - - src=this->screen->pixels; - -// This is the fast, well not too slow, remapping code for 16bit displays - - for(j=this->screen->h;j;--j) - { - destl=(Uint16 *)dest; - - for(k=0;k<this->screen->w;k++) - { - srcl=(Uint16 *)&SDL_XPixels[src[k]]; - *destl=*srcl; - destl++; - } - src+=this->screen->pitch; - dest+=destpitch; - } - UnLockBitMap(handle); - } - } - else if (customroutine==4) - { - unsigned char *bm_address; - Uint32 destpitch; - APTR handle; - - if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address, - LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) - { - register int j,k; - register unsigned char *src,*dest; - register Uint32 *destl,*srcl; - - if(!currently_fullscreen) - dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - else - dest=bm_address; - - src=this->screen->pixels; - -// This is the fast, well not too slow, remapping code for 32bit displays - - for(j=this->screen->h;j;--j) - { - destl=(Uint32 *)dest; - - for(k=0;k<this->screen->w;k++) - { - srcl=(Uint32 *)&SDL_XPixels[src[k]]; - *destl=*srcl; - destl++; - } - src+=this->screen->pitch; - dest+=destpitch; - } - UnLockBitMap(handle); - } -#endif - } - else if(customroutine) - { - unsigned char *bm_address; - Uint32 destpitch; - APTR handle; - - if(handle=LockBitMapTags(SDL_RastPort->BitMap, - LBMI_BASEADDRESS,(ULONG)&bm_address, - LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) - { - register int j; - register unsigned char *src,*dest; - - if(!currently_fullscreen) - dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->screen->format->BytesPerPixel; - else - dest=bm_address; - - src=this->screen->pixels; - -// D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch)); - - if(this->screen->pitch==destpitch) - { - SDL_memcpy(dest,src,this->screen->pitch*this->screen->h); - } - else - { - for(j=this->screen->h;j;--j) - { - SDL_memcpy(dest,src,this->screen->pitch); - src+=this->screen->pitch; - dest+=destpitch; - } - } - - UnLockBitMap(handle); - } - } - else - { - USE_WPA(this->screen->pixels,0,0,this->screen->pitch, - SDL_RastPort,SDL_Window->BorderLeft,SDL_Window->BorderTop, - this->screen->w,this->screen->h,format); - } - -}
--- a/src/video/cybergfx/SDL_cgximage_c.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_cgxvideo.h" - -extern int CGX_SetupImage(_THIS, SDL_Surface *screen); -extern void CGX_DestroyImage(_THIS, SDL_Surface *screen); -extern int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags); - -extern int CGX_AllocHWSurface(_THIS, SDL_Surface *surface); -extern void CGX_FreeHWSurface(_THIS, SDL_Surface *surface); -extern int CGX_LockHWSurface(_THIS, SDL_Surface *surface); -extern void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface); -extern int CGX_FlipHWSurface(_THIS, SDL_Surface *surface); - -extern void CGX_RefreshDisplay(_THIS);
--- a/src/video/cybergfx/SDL_cgxmodes.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,316 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Utilities for getting and setting the X display mode */ - -#include "SDL_timer.h" -#include "SDL_events.h" -#include "../../events/SDL_events_c.h" -#include "SDL_cgxvideo.h" -#include "SDL_cgxwm_c.h" -#include "SDL_cgxmodes_c.h" - -#define CGX_DEBUG - -static void set_best_resolution(_THIS, int width, int height) -{ - Uint32 idok; - int depth=8; - - if(SDL_Display) - depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); - - idok=BestCModeIDTags(CYBRBIDTG_NominalWidth,width, - CYBRBIDTG_NominalHeight,height, - CYBRBIDTG_Depth,depth, - TAG_DONE); - - if(idok!=INVALID_ID) - { - if(SDL_Display) - { - if(currently_fullscreen) - CloseScreen(SDL_Display); - else - UnlockPubScreen(NULL,SDL_Display); - } - SDL_Display=GFX_Display=OpenScreenTags(NULL,SA_Width,width,SA_Height,height, - SA_Depth,depth,SA_DisplayID,idok, - SA_ShowTitle,FALSE, - TAG_DONE); - } -} - -static void get_real_resolution(_THIS, int* w, int* h) -{ - *w = /*SDL_Display->Width*/ SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight; - *h = /*SDL_Display->Height*/ SDL_Window->Height-SDL_Window->BorderBottom-SDL_Window->BorderTop; -} - -static void move_cursor_to(_THIS, int x, int y) -{ -/* XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); */ - -/* DA FARE! */ -} - -static void add_visual(_THIS, int depth, int class) -{ - Uint32 tID; - - tID=BestCModeIDTags(CYBRBIDTG_Depth,depth, - CYBRBIDTG_NominalWidth,640, - CYBRBIDTG_NominalHeight,480, - TAG_DONE); - - if(tID!=INVALID_ID) - { - int n = this->hidden->nvisuals; - - this->hidden->visuals[n].depth = depth; - this->hidden->visuals[n].visual = tID; - this->hidden->visuals[n].bpp = GetCyberIDAttr(CYBRIDATTR_BPPIX,tID); - this->hidden->nvisuals++; - } -} - -#define TrueColor 1 -#define PseudoColor 2 - -int CGX_GetVideoModes(_THIS) -{ - int i; - ULONG nextid; - int nmodes=0; - - SDL_modelist=NULL; - - nextid=NextDisplayInfo(INVALID_ID); - - while(nextid!=INVALID_ID) - { - if(IsCyberModeID(nextid)) - { - DisplayInfoHandle h; - - if(h=FindDisplayInfo(nextid)) - { - struct DimensionInfo info; - - if(GetDisplayInfoData(h,(char *)&info,sizeof(struct DimensionInfo),DTAG_DIMS,NULL)) - { - int ok=0; - - for(i=0;i<nmodes;i++) - { - if( SDL_modelist[i]->w == (info.Nominal.MaxX+1) && - SDL_modelist[i]->h == (info.Nominal.MaxY+1) ) - ok=1; - } - - if(!ok) - { - nmodes++; - - SDL_modelist = (SDL_Rect **)SDL_realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *)); - SDL_modelist[nmodes]=NULL; - - if ( SDL_modelist ) - { - SDL_modelist[nmodes-1] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); - - if ( SDL_modelist[nmodes-1] == NULL ) - break; - - SDL_modelist[nmodes-1]->x = 0; - SDL_modelist[nmodes-1]->y = 0; - SDL_modelist[nmodes-1]->w = info.Nominal.MaxX+1; - SDL_modelist[nmodes-1]->h = info.Nominal.MaxY+1; - } - } - } - } - } - nextid=NextDisplayInfo(nextid); - } - - - this->hidden->nvisuals = 0; - /* Search for the visuals in deepest-first order, so that the first - will be the richest one */ - add_visual(this, 32, TrueColor); - add_visual(this, 24, TrueColor); - add_visual(this, 16, TrueColor); - add_visual(this, 15, TrueColor); - add_visual(this, 8, PseudoColor); - - if(this->hidden->nvisuals == 0) { - SDL_SetError("Found no sufficiently capable CGX visuals"); - return -1; - } - - if ( SDL_modelist == NULL ) { - SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); - i = 0; - if ( SDL_modelist ) { - SDL_modelist[i] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); - if ( SDL_modelist[i] ) { - SDL_modelist[i]->x = 0; - SDL_modelist[i]->y = 0; - SDL_modelist[i]->w = SDL_Display->Width; - SDL_modelist[i]->h = SDL_Display->Height; - ++i; - } - SDL_modelist[i] = NULL; - } - } - - D( if ( SDL_modelist ) { - bug("CGX video mode list: (%ld)\n",nmodes); - for ( i=0; SDL_modelist[i]; ++i ) { - bug( "\t%ld x %ld\n", - SDL_modelist[i]->w, SDL_modelist[i]->h); - } - } - ); - - D( { bug("CGX visuals list: (%ld)\n",this->hidden->nvisuals); - - for(i=0;i<this->hidden->nvisuals;i++) - bug("\t%lx - depth: %ld bpp: %ld\n",this->hidden->visuals[i].visual,this->hidden->visuals[i].depth,this->hidden->visuals[i].bpp); - } - ); - return 0; -} - -int CGX_SupportedVisual(_THIS, SDL_PixelFormat *format) -{ - int i; - for(i = 0; i < this->hidden->nvisuals; i++) - { - if(this->hidden->visuals[i].depth == format->BitsPerPixel) // Era bpp - return 1; - } - return 0; -} - -SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) -{ - if ( CGX_SupportedVisual(this, format) ) { - if ( flags & SDL_FULLSCREEN ) { - return(SDL_modelist); - } else { - return((SDL_Rect **)-1); - } - } else { - return((SDL_Rect **)0); - } -} - -void CGX_FreeVideoModes(_THIS) -{ - int i; - - if ( SDL_modelist ) { - for ( i=0; SDL_modelist[i]; ++i ) { - SDL_free(SDL_modelist[i]); - } - SDL_free(SDL_modelist); - SDL_modelist = NULL; - } -} - -int CGX_ResizeFullScreen(_THIS) -{ - int x, y; - int real_w, real_h; - - if ( currently_fullscreen ) { -/* Per ora non faccio nulla qui */ - } - return(1); -} - -void _QueueEnterFullScreen(_THIS) -{ -} - -int CGX_EnterFullScreen(_THIS) -{ - int okay; - Uint32 saved_flags; - - okay = 1; - saved_flags = this->screen->flags; - - if ( ! currently_fullscreen ) - { - int real_w, real_h; - - /* Map the fullscreen window to blank the screen */ - get_real_resolution(this, &real_w, &real_h); - - CGX_DestroyWindow(this,this->screen); - set_best_resolution(this, real_w,real_h); - - currently_fullscreen = 1; - this->screen->flags = saved_flags; - - CGX_CreateWindow(this,this->screen,real_w,real_h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags); - - /* Set the new resolution */ - okay = CGX_ResizeFullScreen(this); - if ( ! okay ) { - CGX_LeaveFullScreen(this); - } - /* Set the colormap */ -/* - if ( SDL_XColorMap ) { - XInstallColormap(SDL_Display, SDL_XColorMap); - } -*/ - } -// CGX_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); - return(okay); -} - -int CGX_LeaveFullScreen(_THIS) -{ - if ( currently_fullscreen ) { - int width,height; - if ( SDL_Window ) { - CloseWindow(SDL_Window); - SDL_Window=NULL; - } - CloseScreen(SDL_Display); - - GFX_Display=SDL_Display=LockPubScreen(NULL); - - currently_fullscreen = 0; - - CGX_CreateWindow(this,this->screen,this->screen->w,this->screen->h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags); - CGX_ResizeImage(this,this->screen,0L); - } - - return(0); -}
--- a/src/video/cybergfx/SDL_cgxmodes_c.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Utilities for getting and setting the X display mode */ - -#include "SDL_cgxvideo.h" - -/* Define this if you want to grab the keyboard in fullscreen mode. - If you do not define this, SDL will return from SDL_SetVideoMode() - immediately, but will not actually go fullscreen until the window - manager is idle. -*/ -#define GRAB_FULLSCREEN - -extern int CGX_GetVideoModes(_THIS); -extern SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); -extern void CGX_FreeVideoModes(_THIS); -extern int CGX_ResizeFullScreen(_THIS); -/* -extern void CGX_WaitMapped(_THIS, Window win); -extern void CGX_WaitUnmapped(_THIS, Window win); -extern void CGX_QueueEnterFullScreen(_THIS); -*/ -extern int CGX_EnterFullScreen(_THIS); -extern int CGX_LeaveFullScreen(_THIS);
--- a/src/video/cybergfx/SDL_cgxvideo.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1375 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - * CGX based SDL video driver implementation by Gabriele Greco - * gabriele.greco@aruba.it - */ - -#include "SDL_endian.h" -#include "SDL_timer.h" -#include "SDL_thread.h" -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" -#include "SDL_cgxgl_c.h" -#include "SDL_cgxvideo.h" -#include "SDL_cgxwm_c.h" -#include "SDL_amigamouse_c.h" -#include "SDL_amigaevents_c.h" -#include "SDL_cgxmodes_c.h" -#include "SDL_cgximage_c.h" - -/* Initialization/Query functions */ -static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat); -static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); -static int CGX_ToggleFullScreen(_THIS, int on); -static void CGX_UpdateMouse(_THIS); -static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); -static void CGX_VideoQuit(_THIS); - -/* CGX driver bootstrap functions */ - -struct Library *CyberGfxBase=NULL; -struct IntuitionBase *IntuitionBase=NULL; -struct GfxBase *GfxBase=NULL; - -int CGX_SetGamma(_THIS, float red, float green, float blue) -{ - SDL_SetError("Gamma correction not supported"); - return -1; -} - -int CGX_GetGamma(_THIS, float red, float green, float blue) -{ - SDL_SetError("Gamma correction not supported"); - return -1; -} - -int CGX_SetGammaRamp(_THIS, Uint16 *ramp) -{ -#if 0 - Int i, ncolors; - XColor xcmap[256]; - - /* See if actually setting the gamma is supported */ - if ( SDL_Visual->class != DirectColor ) { - SDL_SetError("Gamma correction not supported on this visual"); - return(-1); - } - - /* Calculate the appropriate palette for the given gamma ramp */ - ncolors = SDL_Visual->map_entries; - for ( i=0; i<ncolors; ++i ) { - Uint8 c = (256 * i / ncolors); - xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c); - xcmap[i].red = ramp[0*256+c]; - xcmap[i].green = ramp[1*256+c]; - xcmap[i].blue = ramp[2*256+c]; - xcmap[i].flags = (DoRed|DoGreen|DoBlue); - } - XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors); - XSync(GFX_Display, False); - - return(0); - -#else - SDL_SetError("Gamma correction not supported on this visual"); - return(-1); - -#endif -} - -static void DestroyScreen(_THIS) -{ - if(currently_fullscreen) - { - if(this->hidden->dbuffer) - { - extern struct MsgPort *safeport,*dispport; - - this->hidden->dbuffer=0; - - if(safeport) - { - while(GetMsg(safeport)!=NULL); - DeleteMsgPort(safeport); - } - if(dispport) - { - while(GetMsg(dispport)!=NULL); - DeleteMsgPort(dispport); - } - - this->hidden->SB[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[0]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL; - this->hidden->SB[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL; - - if(this->hidden->SB[1]) - FreeScreenBuffer(SDL_Display,this->hidden->SB[1]); - if(this->hidden->SB[0]) - FreeScreenBuffer(SDL_Display,this->hidden->SB[0]); - - - this->hidden->SB[0]=this->hidden->SB[1]=NULL; - - if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort) - SDL_free(SDL_RastPort); - - SDL_RastPort=NULL; - } - CloseScreen(GFX_Display); - currently_fullscreen=0; - } - else if(GFX_Display) - UnlockPubScreen(NULL,GFX_Display); - - GFX_Display = NULL; -} - -static int CGX_Available(void) -{ - struct Library *l; - - l = OpenLibrary("cybergraphics.library",0L); - - if ( l != NULL ) { - D(bug("CGX video device AVAILABLE\n")); - CloseLibrary(l); - } - D(else bug("**CGX video device UNAVAILABLE\n")); - - return(l != NULL); -} - -static void CGX_DeleteDevice(SDL_VideoDevice *device) -{ - if ( device ) { - if ( device->hidden ) { - SDL_free(device->hidden); - } - if ( device->gl_data ) { - SDL_free(device->gl_data); - } - SDL_free(device); - } -} - -static SDL_VideoDevice *CGX_CreateDevice(int devindex) -{ - SDL_VideoDevice *device; - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); - if ( device ) { - SDL_memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *device->hidden)); - device->gl_data = (struct SDL_PrivateGLData *) - SDL_malloc((sizeof *device->gl_data)); - } - if ( (device == NULL) || (device->hidden == NULL) || - (device->gl_data == NULL) ) { - D(bug("Unable to create video device!\n")); - SDL_OutOfMemory(); - CGX_DeleteDevice(device); - return(0); - } - SDL_memset(device->hidden, 0, sizeof(*device->hidden)); - SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); - - /* Set the driver flags */ - device->handles_any_size = 1; - - /* Set the function pointers */ - device->VideoInit = CGX_VideoInit; - device->ListModes = CGX_ListModes; - device->SetVideoMode = CGX_SetVideoMode; - device->ToggleFullScreen = CGX_ToggleFullScreen; - device->UpdateMouse = CGX_UpdateMouse; - device->SetColors = CGX_SetColors; - device->UpdateRects = NULL; - device->VideoQuit = CGX_VideoQuit; - device->AllocHWSurface = CGX_AllocHWSurface; - device->CheckHWBlit = CGX_CheckHWBlit; - device->FillHWRect = CGX_FillHWRect; - device->SetHWColorKey = CGX_SetHWColorKey; - device->SetHWAlpha = NULL; - device->LockHWSurface = CGX_LockHWSurface; - device->UnlockHWSurface = CGX_UnlockHWSurface; - device->FlipHWSurface = CGX_FlipHWSurface; - device->FreeHWSurface = CGX_FreeHWSurface; - device->SetGamma = CGX_SetGamma; - device->GetGamma = CGX_GetGamma; - device->SetGammaRamp = CGX_SetGammaRamp; - device->GetGammaRamp = NULL; -#if SDL_VIDEO_OPENGL - device->GL_LoadLibrary = CGX_GL_LoadLibrary; - device->GL_GetProcAddress = CGX_GL_GetProcAddress; - device->GL_GetAttribute = CGX_GL_GetAttribute; - device->GL_MakeCurrent = CGX_GL_MakeCurrent; - device->GL_SwapBuffers = CGX_GL_SwapBuffers; -#endif - device->SetIcon = CGX_SetIcon; - device->SetCaption = CGX_SetCaption; - device->IconifyWindow = NULL; /* CGX_IconifyWindow; */ - device->GrabInput = NULL /* CGX_GrabInput*/; - device->GetWMInfo = CGX_GetWMInfo; - device->FreeWMCursor = amiga_FreeWMCursor; - device->CreateWMCursor = amiga_CreateWMCursor; - device->ShowWMCursor = amiga_ShowWMCursor; - device->WarpWMCursor = amiga_WarpWMCursor; - device->CheckMouseMode = amiga_CheckMouseMode; - device->InitOSKeymap = amiga_InitOSKeymap; - device->PumpEvents = amiga_PumpEvents; - - device->free = CGX_DeleteDevice; - - return device; -} - -VideoBootStrap CGX_bootstrap = { - "CGX", "AmigaOS CyberGraphics", CGX_Available, CGX_CreateDevice -}; - -Uint32 MakeBitMask(_THIS,int type,int format,int *bpp) -{ - D(if(type==0)bug("REAL pixel format: ")); - - if(this->hidden->depth==*bpp) - { - - switch(format) - { - case PIXFMT_LUT8: - D(if(type==0)bug("LUT8\n")); - return 0; - case PIXFMT_BGR15: - case PIXFMT_RGB15PC: - switch(type) - { - case 0: - D(bug("RGB15PC/BGR15\n")); - return 31; - case 1: - return 992; - case 2: - return 31744; - } - case PIXFMT_RGB15: - case PIXFMT_BGR15PC: - switch(type) - { - case 0: - D(bug("RGB15/BGR15PC\n")); - return 31744; - case 1: - return 992; - case 2: - return 31; - } - case PIXFMT_BGR16PC: - case PIXFMT_RGB16: - switch(type) - { - case 0: - D(bug("RGB16PC\n")); - return 63488; - case 1: - return 2016; - case 2: - return 31; - } - case PIXFMT_BGR16: - case PIXFMT_RGB16PC: - switch(type) - { - case 0: - D(bug("RGB16PC/BGR16\n")); - return 31; - case 1: - return 2016; - case 2: - return 63488; - } - - case PIXFMT_RGB24: - switch(type) - { - case 0: - D(bug("RGB24/BGR24\n")); - return 0xff0000; - case 1: - return 0xff00; - case 2: - return 0xff; - } - case PIXFMT_BGR24: - switch(type) - { - case 0: - D(bug("BGR24\n")); - return 0xff; - case 1: - return 0xff00; - case 2: - return 0xff0000; - } - case PIXFMT_ARGB32: - switch(type) - { - case 0: - D(bug("ARGB32\n")); - return 0xff0000; - case 1: - return 0xff00; - case 2: - return 0xff; - } - case PIXFMT_BGRA32: - switch(type) - { - case 0: - D(bug("BGRA32\n")); - return 0xff00; - case 1: - return 0xff0000; - case 2: - return 0xff000000; - } - case PIXFMT_RGBA32: - switch(type) - { - case 0: - D(bug("RGBA32\n")); - return 0xff000000; - case 1: - return 0xff0000; - case 2: - return 0xff00; - } - default: - D(bug("Unknown pixel format! Default to 24bit\n")); - return (Uint32) (255<<(type*8)); - } - } - else - { - D(if(type==0)bug("DIFFERENT from screen.\nAllocated screen format: ")); - - switch(*bpp) - { - case 32: - D(if(type==0) bug("RGBA32\n")); - switch(type) - { - case 0: - return 0xff000000; - case 1: - return 0xff0000; - case 2: - return 0xff00; - } - break; - case 24: -use_truecolor: - switch(type) - { - case 0: - D(bug("RGB24\n")); - return 0xff0000; - case 1: - return 0xff00; - case 2: - return 0xff; - } - case 16: - case 15: - D(if(type==0) bug("Not supported, switching to 24bit!\n")); - *bpp=24; - goto use_truecolor; - break; - default: - D(if(type==0)bug("This is a chunky display\n")); -// For chunky display mask is always 0; - return 0; - } - } - return 0; -} - -static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat) -{ - int i; - struct Library *RTGBase; - - D(bug("VideoInit... Opening libraries\n")); - - if(!IntuitionBase) { - if( !(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39L))) { - SDL_SetError("Couldn't open intuition V39+"); - return -1; - } - } - - if(!GfxBase) { - if( !(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39L))) { - SDL_SetError("Couldn't open graphics V39+"); - return -1; - } - } - - if(!CyberGfxBase) { - if( !(CyberGfxBase=OpenLibrary("cybergraphics.library",40L))) { - SDL_SetError("Couldn't open cybergraphics."); - return(-1); - } - } - - if(RTGBase=OpenLibrary("libs:picasso96/rtg.library",0L)) { - extern int use_picasso96; - - CloseLibrary(RTGBase); - use_picasso96=1; - } - - D(bug("Library intialized, locking screen...\n")); - - SDL_Display = LockPubScreen(NULL); - - if ( SDL_Display == NULL ) { - D(bug("Cannot lock display...\n")); - SDL_SetError("Couldn't lock the display"); - return(-1); - } - this->info.current_w = SDL_Display->Width; - this->info.current_h = SDL_Display->Height; - - D(bug("Checking if we are using a CGX native display...\n")); - - if(!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort))) - { - Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,SDL_Display->Width, - CYBRBIDTG_NominalHeight,SDL_Display->Height, - CYBRBIDTG_Depth,8, - TAG_DONE); - - D(bug("Default visual is not CGX native!\n")); - - UnlockPubScreen(NULL,SDL_Display); - - GFX_Display=NULL; - - if(okid!=INVALID_ID) - { - GFX_Display=OpenScreenTags(NULL, - SA_Width,SDL_Display->Width, - SA_Height,SDL_Display->Height, - SA_Depth,8,SA_Quiet,TRUE, - SA_ShowTitle,FALSE, - SA_DisplayID,okid, - TAG_DONE); - } - - if(!GFX_Display) - { - SDL_SetError("Unable to open a suited CGX display"); - return -1; - } - else SDL_Display=GFX_Display; - - } - else GFX_Display = SDL_Display; - - - /* See whether or not we need to swap pixels */ - - swap_pixels = 0; - -// Non e' detto che sia cosi' pero', alcune schede potrebbero gestire i modi in modo differente - - if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) { - swap_pixels = 1; - } - - D(bug("Before GetVideoModes....\n")); - - /* Get the available video modes */ - if(CGX_GetVideoModes(this) < 0) - return -1; - - /* Determine the default screen depth: - Use the default visual (or at least one with the same depth) */ - - for(i = 0; i < this->hidden->nvisuals; i++) - if(this->hidden->visuals[i].depth == GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)) - break; - if(i == this->hidden->nvisuals) { - /* default visual was useless, take the deepest one instead */ - i = 0; - } - SDL_Visual = this->hidden->visuals[i].visual; - -// SDL_XColorMap = SDL_DisplayColormap; - - this->hidden->depth = this->hidden->visuals[i].depth; - D(bug("Init: Setting screen depth to: %ld\n",this->hidden->depth)); - vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */ - - { - int form; - APTR handle; - struct DisplayInfo info; - - if(!(handle=FindDisplayInfo(this->hidden->visuals[i].visual))) - { - D(bug("Unable to get visual info...\n")); - return -1; - } - - if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) { - D(bug("Unable to get visual info data...\n")); - return -1; - } - - form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual); - -// In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask - - if ( vformat->BitsPerPixel > 8 ) - { - vformat->Rmask = MakeBitMask(this,0,form,&this->hidden->depth); - vformat->Gmask = MakeBitMask(this,1,form,&this->hidden->depth); - vformat->Bmask = MakeBitMask(this,2,form,&this->hidden->depth); - } - } - - /* See if we have been passed a window to use */ -/* SDL_windowid = SDL_getenv("SDL_WINDOWID"); */ - SDL_windowid=NULL; - - /* Create the blank cursor */ - SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR); - - /* Fill in some window manager capabilities */ - this->info.wm_available = 1; - this->info.blit_hw = 1; - this->info.blit_hw_CC = 1; - this->info.blit_sw = 1; - this->info.blit_fill = 1; - this->info.video_mem=2000000; // Not always true but almost any Amiga card has this memory! - - this->hidden->same_format=0; - SDL_RastPort=&SDL_Display->RastPort; - /* We're done! */ - D(bug("End of CGX_VideoInit\n")); - - return(0); -} - -void CGX_DestroyWindow(_THIS, SDL_Surface *screen) -{ - D(bug("Destroy Window...\n")); - - if ( ! SDL_windowid ) { - /* Hide the managed window */ - int was_fullscreen=0; - - /* Clean up OpenGL */ - if ( screen ) { - screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT); - } - - if ( screen && (screen->flags & SDL_FULLSCREEN) ) { - was_fullscreen=1; - screen->flags &= ~SDL_FULLSCREEN; -// CGX_LeaveFullScreen(this); tolto x crash - } - - /* Destroy the output window */ - if ( SDL_Window ) { - CloseWindow(SDL_Window); - SDL_Window=NULL; - } - - /* Free the colormap entries */ - if ( SDL_XPixels ) { - int numcolors; - unsigned long pixel; - - if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen) - { - numcolors = 1<<this->screen->format->BitsPerPixel; - - if(numcolors>256) - numcolors=256; - - if(!was_fullscreen&&this->hidden->depth==8) - { - for ( pixel=0; pixel<numcolors; pixel++ ) - { - if(SDL_XPixels[pixel]>=0) - ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); - } - } - } - SDL_free(SDL_XPixels); - SDL_XPixels = NULL; - } - } -} - -static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) -{ - if ( flags & SDL_RESIZABLE ) { - WindowLimits(SDL_Window, 32, 32,4096,4096); - } else { - WindowLimits(SDL_Window, w,h,w,h); - } - if ( flags & SDL_FULLSCREEN ) { - flags&=~SDL_RESIZABLE; - } else if ( SDL_getenv("SDL_VIDEO_CENTERED") ) { - int display_w, display_h; - - display_w = SDL_Display->Width; - display_h = SDL_Display->Height; - ChangeWindowBox(SDL_Window,(display_w - w - SDL_Window->BorderLeft-SDL_Window->BorderRight)/2, - (display_h - h - SDL_Window->BorderTop-SDL_Window->BorderBottom)/2, - w+SDL_Window->BorderLeft+SDL_Window->BorderRight, - h+SDL_Window->BorderTop+SDL_Window->BorderBottom); - } -} - -int CGX_CreateWindow(_THIS, SDL_Surface *screen, - int w, int h, int bpp, Uint32 flags) -{ -#if 0 - int i, depth; - Uint32 vis; -#endif - D(bug("CGX_CreateWindow\n")); - - /* If a window is already present, destroy it and start fresh */ - if ( SDL_Window ) { - CGX_DestroyWindow(this, screen); - } - - /* See if we have been given a window id */ - if ( SDL_windowid ) { - SDL_Window = (struct Window *)atol(SDL_windowid); - } else { - SDL_Window = 0; - } - - /* find out which visual we are going to use */ -#if 0 -/* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre - hanno il pixel mode degli schermi. - */ - /*if ( flags & SDL_OPENGL ) { - SDL_SetError("OpenGL not supported by the Amiga SDL!"); - return -1; - } - else {*/ - for ( i = 0; i < this->hidden->nvisuals; i++ ) { - if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ - break; - } - if ( i == this->hidden->nvisuals ) { - SDL_SetError("No matching visual for requested depth"); - return -1; /* should never happen */ - } - vis = this->hidden->visuals[i].visual; - depth = this->hidden->visuals[i].depth; -// } - SDL_Visual = vis; - this->hidden->depth = depth; - D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); -#endif - - /* Allocate the new pixel format for this video mode */ - { - Uint32 form; - APTR handle; - struct DisplayInfo info; - - if(!(handle=FindDisplayInfo(SDL_Visual))) - return -1; - - if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) - return -1; - - form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual); - - if(flags&SDL_HWSURFACE) - { - if(bpp!=this->hidden->depth) - { - bpp=this->hidden->depth; - D(bug("Accel forces bpp to be equal (%ld)\n",bpp)); - } - } - - D(bug("BEFORE screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); - -/* With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs - only with requested format 15/16bit and display format != 15/16bit - */ - - if ( ! SDL_ReallocFormat(screen, bpp, - MakeBitMask(this,0,form,&bpp), MakeBitMask(this,1,form,&bpp), MakeBitMask(this,2,form,&bpp), 0) ) - return -1; - - D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); - - } - - /* Create the appropriate colormap */ -/* - if ( SDL_XColorMap != SDL_DisplayColormap ) { - XFreeColormap(SDL_Display, SDL_XColorMap); - } -*/ - if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) { - int ncolors,i; - D(bug("XPixels palette allocation...\n")); - - /* Allocate the pixel flags */ - - if(bpp==8) - ncolors=256; - else - ncolors = 1 << screen->format->BitsPerPixel; - - SDL_XPixels = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32)); - - if(SDL_XPixels == NULL) { - SDL_OutOfMemory(); - return -1; - } - - - for(i=0;i<ncolors;i++) - SDL_XPixels[i]=-1; - - /* always allocate a private colormap on non-default visuals */ - if(bpp==8) - flags |= SDL_HWPALETTE; - - if ( flags & SDL_HWPALETTE ) - screen->flags |= SDL_HWPALETTE; - } - - /* resize the (possibly new) window manager window */ - - /* Create (or use) the X11 display window */ - - if ( !SDL_windowid ) { - if( flags & SDL_FULLSCREEN ) - { - SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h, - WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE, - WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE, - WA_CustomScreen,(ULONG)SDL_Display, - TAG_DONE); - - D(bug("Opening backdrop window %ldx%ld on display %lx!\n",w,h,SDL_Display)); - } - else - { - /* Create GimmeZeroZero window when OpenGL is used */ - unsigned long gzz = FALSE; - if( flags & SDL_OPENGL ) { - gzz = TRUE; - } - - SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h, - 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))), - WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE, - WA_PubScreen,(ULONG)SDL_Display, - WA_GimmeZeroZero, gzz, - TAG_DONE); - D(bug("Opening WB window of size: %ldx%ld!\n",w,h)); - } - - if(!SDL_Window) - return -1; - } - - this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX); - - if(screen->flags & SDL_DOUBLEBUF) - { - if(SDL_RastPort=SDL_malloc(sizeof(struct RastPort))) - { - InitRastPort(SDL_RastPort); - SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap; - } - else - return -1; - } - else SDL_RastPort=SDL_Window->RPort; - - if(flags&SDL_HWSURFACE) - screen->flags|=SDL_HWSURFACE; - - if( !SDL_windowid ) { - CGX_SetSizeHints(this, w, h, flags); - } - - /* Set our colormaps when not setting a GL mode */ -/* - if ( ! (flags & SDL_OPENGL) ) { - XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap); - } -*/ - - /* Map them both and go fullscreen, if requested */ - if ( ! SDL_windowid ) { - if ( flags & SDL_FULLSCREEN ) { - screen->flags |= SDL_FULLSCREEN; - currently_fullscreen=1; -// CGX_EnterFullScreen(this); Ci siamo gia'! - } else { - screen->flags &= ~SDL_FULLSCREEN; - } - } - screen->w = w; - screen->h = h; - screen->pitch = SDL_CalculatePitch(screen); - CGX_ResizeImage(this, screen, flags); - - /* Make OpenGL Context if needed*/ - if(flags & SDL_OPENGL) { - if(this->gl_data->gl_active == 0) { - if(CGX_GL_Init(this) < 0) - return -1; - else - screen->flags |= SDL_OPENGL; - } - else { - if(CGX_GL_Update(this) < 0) - return -1; - else - screen->flags |= SDL_OPENGL; - } - } -} - -int CGX_ResizeWindow(_THIS, - SDL_Surface *screen, int w, int h, Uint32 flags) -{ - D(bug("CGX_ResizeWindow\n")); - - if ( ! SDL_windowid ) { - /* Resize the window manager window */ - CGX_SetSizeHints(this, w, h, flags); - - ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight, - h+SDL_Window->BorderTop+SDL_Window->BorderBottom); - - screen->w = w; - screen->h = h; - screen->pitch = SDL_CalculatePitch(screen); - CGX_ResizeImage(this, screen, flags); - } - return(0); -} - -static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, - int width, int height, int bpp, Uint32 flags) -{ - Uint32 saved_flags; - int needcreate=0; - - D(bug("CGX_SetVideoMode current:%lx\n",current)); - - /* Lock the event thread, in multi-threading environments */ - SDL_Lock_EventThread(); - -// Check if the window needs to be closed or can be resized - - if( (flags&SDL_FULLSCREEN) || (current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN))) - needcreate=1; - -// Check if we need to close an already existing videomode... - - if(current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)) { - unsigned long i; - D(bug("Destroying image, window & screen!\n")); - - CGX_DestroyImage(this,current); - CGX_DestroyWindow(this,current); - DestroyScreen(this); - GFX_Display=SDL_Display=LockPubScreen(NULL); - - bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); - - for ( i = 0; i < this->hidden->nvisuals; i++ ) { - if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ - break; - } - if ( i == this->hidden->nvisuals ) { - SDL_SetError("No matching visual for requested depth"); - return NULL; /* should never happen */ - } - SDL_Visual = this->hidden->visuals[i].visual; - - D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); - - } - /* Check the combination of flags we were passed */ - if ( flags & SDL_FULLSCREEN ) { - int i; - - /* Clear fullscreen flag if not supported */ - if ( SDL_windowid ) { - flags &= ~SDL_FULLSCREEN; - } - else if(current && current->flags&SDL_FULLSCREEN ) { - if(current->w!=width || - current->h!=height || - (this->hidden && this->hidden->depth!=bpp)) - { - D(bug("Deleting previous window...\n")); - CGX_DestroyImage(this,current); - CGX_DestroyWindow(this,current); - DestroyScreen(this); - goto buildnewscreen; - } - } - else -buildnewscreen: - { - Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,width, - CYBRBIDTG_NominalHeight,height, - CYBRBIDTG_Depth,bpp, - TAG_DONE); - - GFX_Display=NULL; - - D(bug("Opening screen...\n")); - - if(okid!=INVALID_ID) - GFX_Display=OpenScreenTags(NULL, - SA_Width,width, - SA_Height,height, - SA_Quiet,TRUE,SA_ShowTitle,FALSE, - SA_Depth,bpp, - SA_DisplayID,okid, - TAG_DONE); - - if(!GFX_Display) { - GFX_Display=SDL_Display; - flags &= ~SDL_FULLSCREEN; - flags &= ~SDL_DOUBLEBUF; - } - else { - UnlockPubScreen(NULL,SDL_Display); - SDL_Display=GFX_Display; - - D(bug("Screen opened.\n")); - - if(flags&SDL_DOUBLEBUF) { - int ok=0; - D(bug("Start of DBuffering allocations...\n")); - - if(this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP)) { - - if(this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,0L)) { - extern struct MsgPort *safeport,*dispport; - - safeport=CreateMsgPort(); - dispport=CreateMsgPort(); - - if(!safeport || !dispport) { - if(safeport) { - DeleteMsgPort(safeport); - safeport=NULL; - } - if(dispport) { - DeleteMsgPort(dispport); - dispport=NULL; - } - FreeScreenBuffer(SDL_Display,this->hidden->SB[0]); - FreeScreenBuffer(SDL_Display,this->hidden->SB[1]); - } - else { - extern ULONG safe_sigbit,disp_sigbit; - int i; - - safe_sigbit=1L<< safeport->mp_SigBit; - disp_sigbit=1L<< dispport->mp_SigBit; - - for(i=0;i<2;i++) { - this->hidden->SB[i]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=safeport; - this->hidden->SB[i]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=dispport; - } - - ok=1; - D(bug("Dbuffering enabled!\n")); - this->hidden->dbuffer=1; - current->flags|=SDL_DOUBLEBUF; - } - } - else { - FreeScreenBuffer(SDL_Display,this->hidden->SB[1]); - this->hidden->SB[0]=NULL; - } - } - - if(!ok) - flags&=~SDL_DOUBLEBUF; - } - } - - if(GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)==bpp) - this->hidden->same_format=1; - } - - bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); - D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); - - for ( i = 0; i < this->hidden->nvisuals; i++ ) - if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ - break; - - if ( i == this->hidden->nvisuals ) { - SDL_SetError("No matching visual for requested depth"); - return NULL; /* should never happen */ - } - SDL_Visual = this->hidden->visuals[i].visual; - - } - - /* Set up the X11 window */ - saved_flags = current->flags; - - if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL) - && bpp == current->format->BitsPerPixel && !needcreate) { - if (CGX_ResizeWindow(this, current, width, height, flags) < 0) { - current = NULL; - goto done; - } - } else { - if (CGX_CreateWindow(this,current,width,height,bpp,flags) < 0) { - current = NULL; - goto done; - } - } - -#if 0 - /* Set up the new mode framebuffer */ - if ( ((current->w != width) || (current->h != height)) || - ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) { - current->w = width; - current->h = height; - current->pitch = SDL_CalculatePitch(current); - CGX_ResizeImage(this, current, flags); - } -#endif - - current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it - - done: - /* Release the event thread */ - SDL_Unlock_EventThread(); - - /* We're done! */ - return(current); -} - -static int CGX_ToggleFullScreen(_THIS, int on) -{ - Uint32 event_thread; - - /* Don't switch if we don't own the window */ - if ( SDL_windowid ) { - return(0); - } - - /* Don't lock if we are the event thread */ - event_thread = SDL_EventThreadID(); - if ( event_thread && (SDL_ThreadID() == event_thread) ) { - event_thread = 0; - } - if ( event_thread ) { - SDL_Lock_EventThread(); - } - if ( on ) { - this->screen->flags |= SDL_FULLSCREEN; - CGX_EnterFullScreen(this); - } else { - this->screen->flags &= ~SDL_FULLSCREEN; - CGX_LeaveFullScreen(this); - } - - CGX_RefreshDisplay(this); - if ( event_thread ) { - SDL_Unlock_EventThread(); - } - - SDL_ResetKeyboard(); - - return(1); -} - -static void SetSingleColor(Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, unsigned char *c) -{ - switch(fmt) - { - case PIXFMT_BGR15: - case PIXFMT_RGB15PC: - { - Uint16 *t=(Uint16 *)c; - *t=(r>>3) | ((g>>3)<<5) | ((b>>3)<<10) ; - } - break; - case PIXFMT_RGB15: - case PIXFMT_BGR15PC: - { - Uint16 *t=(Uint16 *)c; - *t=(b>>3) | ((g>>3)<<5) | ((r>>3)<<10) ; - } - break; - case PIXFMT_BGR16PC: - case PIXFMT_RGB16: - { - Uint16 *t=(Uint16 *)c; - *t=(b>>3) | ((g>>2)<<5) | ((r>>3)<<11) ; - } - break; - case PIXFMT_BGR16: - case PIXFMT_RGB16PC: - { - Uint16 *t=(Uint16 *)c; - *t=(r>>3) | ((g>>2)<<5) | ((b>>3)<<11) ; - } - break; - case PIXFMT_RGB24: - c[0]=r; - c[1]=g; - c[2]=b; - c[3]=0; - break; - case PIXFMT_BGR24: - c[0]=b; - c[1]=g; - c[2]=r; - c[3]=0; - break; - case PIXFMT_ARGB32: - c[0]=0; - c[1]=r; - c[2]=g; - c[3]=b; - break; - case PIXFMT_BGRA32: - c[0]=b; - c[1]=g; - c[2]=r; - c[3]=0; - break; - case PIXFMT_RGBA32: - c[0]=r; - c[1]=g; - c[2]=b; - c[3]=0; - break; - - default: - D(bug("Error, SetSingleColor with PIXFMT %ld!\n",fmt)); - } -} - -/* Update the current mouse state and position */ -static void CGX_UpdateMouse(_THIS) -{ - /* Lock the event thread, in multi-threading environments */ - SDL_Lock_EventThread(); - - if(currently_fullscreen) - { - SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, SDL_Display->MouseY); - } - else - { - if( SDL_Display->MouseX>=(SDL_Window->LeftEdge+SDL_Window->BorderLeft) && SDL_Display->MouseX<(SDL_Window->LeftEdge+SDL_Window->Width-SDL_Window->BorderRight) && - SDL_Display->MouseY>=(SDL_Window->TopEdge+SDL_Window->BorderLeft) && SDL_Display->MouseY<(SDL_Window->TopEdge+SDL_Window->Height-SDL_Window->BorderBottom) - ) - { - SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft, - SDL_Display->MouseY-SDL_Window->TopEdge-SDL_Window->BorderTop); - } - else - { - SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); - } - } - SDL_Unlock_EventThread(); -} - -static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) -{ - int i; - - /* Check to make sure we have a colormap allocated */ - - /* It's easy if we have a hidden colormap */ - if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) - { - ULONG xcmap[256*3+2]; - - xcmap[0]=(ncolors<<16); - xcmap[0]+=firstcolor; - -// D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors)); - - for ( i=0; i<ncolors; i++ ) { - xcmap[i*3+1] = colors[i+firstcolor].r<<24; - xcmap[i*3+2] = colors[i+firstcolor].g<<24; - xcmap[i*3+3] = colors[i+firstcolor].b<<24; - } - xcmap[ncolors*3+1]=0; - LoadRGB32(&GFX_Display->ViewPort,xcmap); - } else { -// XPixels are not needed on 8bit screen with hwpalette - unsigned long pixel; - - if ( SDL_XPixels == NULL ) { - D(bug("SetColors without colormap!")); - return(0); - } - - if(this->hidden->depth==8) - { -// In this case I have to unalloc and realloc the full palette - D(bug("Obtaining %ld colors on the screen\n",ncolors)); - - /* Free existing allocated colors */ - for ( pixel=0; pixel<this->screen->format->palette->ncolors; ++pixel ) { - if(SDL_XPixels[pixel]>=0) - ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); - } - - /* Try to allocate all the colors */ - for ( i=0; i<this->screen->format->palette->ncolors; ++i ) { - SDL_XPixels[i]=ObtainBestPenA(GFX_Display->ViewPort.ColorMap,colors[i].r<<24,colors[i].g<<24,colors[i].b<<24,NULL); - } - } - else - { -#ifndef USE_CGX_WRITELUTPIXEL - Uint32 fmt; - D(bug("Preparing a conversion pixel table...\n")); - - fmt=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT); - - for(i=0;i<ncolors;i++) - { - SetSingleColor(fmt,colors[firstcolor+i].r,colors[firstcolor+i].g,colors[firstcolor+i].b,(unsigned char *)&SDL_XPixels[firstcolor+i]); - } -#else -// 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)); - for(i=0;i<ncolors;i++) - SDL_XPixels[i+firstcolor]=(colors[firstcolor+i].r<<16)+(colors[firstcolor+i].g<<8)+colors[firstcolor+i].b; -#endif - } - } - -// Actually it cannot fail! - - return 1; -} - -/* Note: If we are terminated, this could be called in the middle of - another SDL video routine -- notably UpdateRects. -*/ -static void CGX_VideoQuit(_THIS) -{ - /* Shutdown everything that's still up */ - /* The event thread should be done, so we can touch SDL_Display */ - D(bug("CGX_VideoQuit\n")); - - if ( SDL_Display != NULL ) { - /* Clean up OpenGL */ - if(this->gl_data->gl_active == 1) { - CGX_GL_Quit(this); - } - /* Start shutting down the windows */ - D(bug("Destroying image...\n")); - CGX_DestroyImage(this, this->screen); - D(bug("Destroying window...\n")); - CGX_DestroyWindow(this, this->screen); -// Otherwise SDL_VideoQuit will try to free it! - SDL_VideoSurface=NULL; - - CGX_FreeVideoModes(this); - - /* Free that blank cursor */ - if ( SDL_BlankCursor != NULL ) { - FreeMem(SDL_BlankCursor,16); - SDL_BlankCursor = NULL; - } - - /* Close the X11 graphics connection */ - this->hidden->same_format=0; - - D(bug("Destroying screen...\n")); - - if ( GFX_Display != NULL ) - DestroyScreen(this); - - /* Close the X11 display connection */ - SDL_Display = NULL; - - /* Unload GL library after X11 shuts down */ - } - - D(bug("Closing libraries...\n")); - - if( CyberGfxBase) { - CloseLibrary(CyberGfxBase); - CyberGfxBase=NULL; - } - - if (IntuitionBase) { - CloseLibrary((struct Library *)IntuitionBase); - IntuitionBase=NULL; - } - if (GfxBase) { - CloseLibrary((struct Library *)GfxBase); - GfxBase=NULL; - } - - if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) { - /* Direct screen access, no memory buffer */ - this->screen->pixels = NULL; - } - D(bug("End of CGX_VideoQuit.\n")); - -} -
--- a/src/video/cybergfx/SDL_cgxvideo.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,172 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_cgxvideo_h -#define _SDL_cgxvideo_h - - -#include <exec/exec.h> -#include <cybergraphx/cybergraphics.h> -#include <graphics/scale.h> -#include <graphics/gfx.h> -#include <intuition/intuition.h> -#if defined(__SASC) || defined(STORMC4_WOS) -#include <proto/exec.h> -#include <proto/cybergraphics.h> -#include <proto/graphics.h> -#include <proto/intuition.h> -#include <proto/console.h> -#else -#include <inline/exec.h> -#include <inline/cybergraphics.h> -#include <inline/graphics.h> -#include <inline/intuition.h> -#include <inline/console.h> -#endif - -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "mydebug.h" - -#define USE_CGX_WRITELUTPIXEL - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *this - -/* Private display data */ -struct SDL_PrivateVideoData { - struct Screen *Public_Display; /* Used for events and window management */ - struct Screen *GFX_Display; /* Used for graphics and colormap stuff */ - Uint32 SDL_VisualUnused; /* The visual used by our window */ - struct Window *SDL_Window; /* Shared by both displays (no X security?) */ - unsigned char *BlankCursor; /* The invisible cursor */ - - char *SDL_windowid; /* Flag: true if we have been passed a window */ - - /* The variables used for displaying graphics */ - Uint8 *Ximage; /* The X image for our window */ - int swap_pixels; /* Flag: true if display is swapped endian */ - - /* Support for internal mouse warping */ - struct { - int x; - int y; - } mouse_last; - struct { - int numerator; - int denominator; - int threshold; - } mouse_accel; - int mouse_relative; - - /* The current list of available video modes */ - SDL_Rect **modelist; - - /* available visuals of interest to us, sorted deepest first */ - struct { - Uint32 visual; - int depth; /* number of significant bits/pixel */ - int bpp; /* pixel quantum in bits */ - } visuals[5]; /* at most entries for 8, 15, 16, 24 */ - int nvisuals; - - Uint32 vis; /* current visual in use */ - int depth; /* current visual depth (not bpp) */ - int BytesPerPixel; - int currently_fullscreen,same_format,dbuffer; - - /* Automatic mode switching support (entering/leaving fullscreen) */ - Uint32 switch_waiting; - Uint32 switch_time; - - /* Prevent too many XSync() calls */ - int blit_queued; - - /* Colormap handling */ - LONG Pens; - Sint32 *XPixels; /* A list of pixels that have been allocated, the size depends on the screen format */ - struct ScreenBuffer *SB[2]; - struct RastPort *RP; - short *iconcolors; /* List of colors used by the icon */ -}; - -/* Old variable names */ -#define local_X11 (this->hidden->local_X11) -#define SDL_Display (this->hidden->Public_Display) -#define GFX_Display (this->hidden->GFX_Display) -#define SDL_Screen DefaultScreen(this->hidden->Public_Display) - -#define SDL_Visual (this->hidden->vis) - -#define SDL_Root RootWindow(SDL_Display, SDL_Screen) -#define WMwindow (this->hidden->WMwindow) -#define FSwindow (this->hidden->FSwindow) -#define SDL_Window (this->hidden->SDL_Window) -#define WM_DELETE_WINDOW (this->hidden->WM_DELETE_WINDOW) -#define SDL_BlankCursor (this->hidden->BlankCursor) -#define SDL_windowid (this->hidden->SDL_windowid) -#define SDL_Ximage (this->hidden->Ximage) -#define SDL_GC (this->hidden->gc) -#define swap_pixels (this->hidden->swap_pixels) -#define mouse_last (this->hidden->mouse_last) -#define mouse_accel (this->hidden->mouse_accel) -#define mouse_relative (this->hidden->mouse_relative) -#define SDL_modelist (this->hidden->modelist) -#define SDL_RastPort (this->hidden->RP) -#define saved_mode (this->hidden->saved_mode) -#define saved_view (this->hidden->saved_view) -#define currently_fullscreen (this->hidden->currently_fullscreen) -#define blit_queued (this->hidden->blit_queued) -#define SDL_DisplayColormap (this->hidden->GFX_Display->ViewPort.ColorMap) -#define SDL_XPixels (this->hidden->XPixels) -#define SDL_iconcolors (this->hidden->iconcolors) - -/* Used to get the X cursor from a window-manager specific cursor */ -// extern Cursor SDL_GetWMXCursor(WMcursor *cursor); - -extern int CGX_CreateWindow(_THIS, SDL_Surface *screen, - int w, int h, int bpp, Uint32 flags); -extern int CGX_ResizeWindow(_THIS, - SDL_Surface *screen, int w, int h, Uint32 flags); - -extern void CGX_DestroyWindow(_THIS, SDL_Surface *screen); - -extern struct Library *CyberGfxBase; -extern struct IntuitionBase *IntuitionBase; -extern struct GfxBase *GfxBase; -extern struct ExecBase *SysBase; -extern struct DosLibrary *DOSBase; - -struct private_hwdata -{ - struct BitMap *bmap; - APTR lock; - struct SDL_VideoDevice *videodata; - APTR mask; - int allocated; -}; - -int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst); -int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color); -int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key); -#endif /* _SDL_x11video_h */
--- a/src/video/cybergfx/SDL_cgxwm.c Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_version.h" -#include "SDL_timer.h" -#include "SDL_video.h" -#include "SDL_syswm.h" -#include "../../events/SDL_events_c.h" -#include "../SDL_pixels_c.h" -#include "SDL_cgxmodes_c.h" -#include "SDL_cgxwm_c.h" - -/* This is necessary for working properly with Enlightenment, etc. */ -#define USE_ICON_WINDOW - -void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) -{ -/* Not yet implemented */ -} - -void CGX_SetCaption(_THIS, const char *title, const char *icon) -{ - if(SDL_Window) - SetWindowTitles(SDL_Window,(char *)title,NULL); -} - -/* Iconify the window */ -int CGX_IconifyWindow(_THIS) -{ -/* Not yet implemented */ - return 0; -} - -int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info) -{ - if ( info->version.major <= SDL_MAJOR_VERSION ) { - return(1); - } else { - SDL_SetError("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); - return(-1); - } -}
--- a/src/video/cybergfx/SDL_cgxwm_c.h Sun Oct 29 03:44:25 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_cgxvideo.h" - -/* Functions to be exported */ -extern void CGX_SetCaption(_THIS, const char *title, const char *icon); -extern void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask); -extern int CGX_IconifyWindow(_THIS); -extern SDL_GrabMode CGX_GrabInputNoLock(_THIS, SDL_GrabMode mode); -extern SDL_GrabMode CGX_GrabInput(_THIS, SDL_GrabMode mode); -extern int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info); -