Commit 28c9fb92 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Removed AmigaOS code for 1.3 branch.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402215
parent 2ec5b5b3
...@@ -190,15 +190,3 @@ AIX: -= NOT YET SUPPORTED =- ...@@ -190,15 +190,3 @@ AIX: -= NOT YET SUPPORTED =-
More information on this port is available at: More information on this port is available at:
http://www.kom.e-technik.tu-darmstadt.de/~griff/SDL/ 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
...@@ -14,7 +14,7 @@ and 2D framebuffer across multiple platforms. ...@@ -14,7 +14,7 @@ and 2D framebuffer across multiple platforms.
The current version supports Linux, Windows, Windows CE, BeOS, MacOS, The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. 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. 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 SDL is written in C, but works with C++ natively, and has bindings to
......
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:
- 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 :( )
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,...)
{
}
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:
Gabriele Greco (gabriele.greco@aruba.it)
You can find also a small SDL Amiga page at:
http://ggreco.interfree.it/sdl.html
...@@ -38,7 +38,7 @@ and 2D framebuffer across multiple platforms. ...@@ -38,7 +38,7 @@ and 2D framebuffer across multiple platforms.
The current version supports Linux, Windows, Windows CE, BeOS, MacOS, The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. 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. 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 SDL is written in C, but works with C++ natively, and has bindings to
......
...@@ -26,9 +26,7 @@ ...@@ -26,9 +26,7 @@
#include "SDL_platform.h" #include "SDL_platform.h"
/* Add any platform that doesn't build using the configure system */ /* Add any platform that doesn't build using the configure system */
#if defined(__AMIGA__) #if defined(__DREAMCAST__)
#include "SDL_config_amiga.h"
#elif defined(__DREAMCAST__)
#include "SDL_config_dreamcast.h" #include "SDL_config_dreamcast.h"
#elif defined(__MACOSX__) #elif defined(__MACOSX__)
#include "SDL_config_macosx.h" #include "SDL_config_macosx.h"
......
...@@ -149,7 +149,6 @@ ...@@ -149,7 +149,6 @@
#undef SDL_VIDEO_DISABLED #undef SDL_VIDEO_DISABLED
/* Enable various audio drivers */ /* Enable various audio drivers */
#undef SDL_AUDIO_DRIVER_AHI
#undef SDL_AUDIO_DRIVER_ALSA #undef SDL_AUDIO_DRIVER_ALSA
#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
#undef SDL_AUDIO_DRIVER_ARTS #undef SDL_AUDIO_DRIVER_ARTS
...@@ -195,7 +194,6 @@ ...@@ -195,7 +194,6 @@
/* Enable various input drivers */ /* Enable various input drivers */
#undef SDL_INPUT_TSLIB #undef SDL_INPUT_TSLIB
#undef SDL_JOYSTICK_AMIGA
#undef SDL_JOYSTICK_BEOS #undef SDL_JOYSTICK_BEOS
#undef SDL_JOYSTICK_DC #undef SDL_JOYSTICK_DC
#undef SDL_JOYSTICK_DINPUT #undef SDL_JOYSTICK_DINPUT
...@@ -220,7 +218,6 @@ ...@@ -220,7 +218,6 @@
#undef SDL_LOADSO_WIN32 #undef SDL_LOADSO_WIN32
/* Enable various threading systems */ /* Enable various threading systems */
#undef SDL_THREAD_AMIGA
#undef SDL_THREAD_BEOS #undef SDL_THREAD_BEOS
#undef SDL_THREAD_DC #undef SDL_THREAD_DC
#undef SDL_THREAD_EPOC #undef SDL_THREAD_EPOC
...@@ -233,7 +230,6 @@ ...@@ -233,7 +230,6 @@
#undef SDL_THREAD_WIN32 #undef SDL_THREAD_WIN32
/* Enable various timer systems */ /* Enable various timer systems */
#undef SDL_TIMER_AMIGA
#undef SDL_TIMER_BEOS #undef SDL_TIMER_BEOS
#undef SDL_TIMER_DC #undef SDL_TIMER_DC
#undef SDL_TIMER_DUMMY #undef SDL_TIMER_DUMMY
...@@ -248,7 +244,6 @@ ...@@ -248,7 +244,6 @@
/* Enable various video drivers */ /* Enable various video drivers */
#undef SDL_VIDEO_DRIVER_BWINDOW #undef SDL_VIDEO_DRIVER_BWINDOW
#undef SDL_VIDEO_DRIVER_COCOA #undef SDL_VIDEO_DRIVER_COCOA
#undef SDL_VIDEO_DRIVER_CYBERGRAPHICS
#undef SDL_VIDEO_DRIVER_DC #undef SDL_VIDEO_DRIVER_DC
#undef SDL_VIDEO_DRIVER_DIRECTFB #undef SDL_VIDEO_DRIVER_DIRECTFB
#undef SDL_VIDEO_DRIVER_DUMMY #undef SDL_VIDEO_DRIVER_DUMMY
......
/*
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 */
...@@ -29,10 +29,6 @@ ...@@ -29,10 +29,6 @@
#undef __AIX__ #undef __AIX__
#define __AIX__ 1 #define __AIX__ 1
#endif #endif
#if defined(AMIGA) || defined(__AMIGA) || defined(__amigados__)
#undef __AMIGA__
#define __AMIGA__ 1
#endif
#if defined(__BEOS__) #if defined(__BEOS__)
#undef __BEOS__ #undef __BEOS__
#define __BEOS__ 1 #define __BEOS__ 1
......
/*
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 */
/* vi: set ts=4 sw=4 expandtab: */
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
/* Need the definitions of SYS_ThreadHandle */ /* Need the definitions of SYS_ThreadHandle */
#if SDL_THREADS_DISABLED #if SDL_THREADS_DISABLED
#include "generic/SDL_systhread_c.h" #include "generic/SDL_systhread_c.h"
#elif SDL_THREAD_AMIGA
#include "amigaos/SDL_systhread_c.h"
#elif SDL_THREAD_BEOS #elif SDL_THREAD_BEOS
#include "beos/SDL_systhread_c.h" #include "beos/SDL_systhread_c.h"
#elif SDL_THREAD_DC #elif SDL_THREAD_DC
......
/*
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;
}
/* vi: set ts=4 sw=4 expandtab: */
/*
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);
}
/* vi: set ts=4 sw=4 expandtab: */
/*
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 */
/* vi: set ts=4 sw=4 expandtab: */
/*
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);
}
}
/* vi: set ts=4 sw=4 expandtab: */
/*
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 */
/* vi: set ts=4 sw=4 expandtab: */
...@@ -344,9 +344,6 @@ extern VideoBootStrap WIN32_bootstrap; ...@@ -344,9 +344,6 @@ extern VideoBootStrap WIN32_bootstrap;
#if SDL_VIDEO_DRIVER_BWINDOW #if SDL_VIDEO_DRIVER_BWINDOW
extern VideoBootStrap BWINDOW_bootstrap; extern VideoBootStrap BWINDOW_bootstrap;
#endif #endif
#if SDL_VIDEO_DRIVER_CYBERGRAPHICS
extern VideoBootStrap CGX_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_PHOTON #if SDL_VIDEO_DRIVER_PHOTON
extern VideoBootStrap ph_bootstrap; extern VideoBootStrap ph_bootstrap;
#endif #endif
......
...@@ -82,9 +82,6 @@ static VideoBootStrap *bootstrap[] = { ...@@ -82,9 +82,6 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_BWINDOW #if SDL_VIDEO_DRIVER_BWINDOW
&BWINDOW_bootstrap, &BWINDOW_bootstrap,
#endif #endif
#if SDL_VIDEO_DRIVER_CYBERGRAPHICS
&CGX_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_PHOTON #if SDL_VIDEO_DRIVER_PHOTON
&ph_bootstrap, &ph_bootstrap,
#endif #endif
......
This diff is collapsed.
/*
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);
/* vi: set ts=4 sw=4 expandtab: */
/*
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)
{
}
/* vi: set ts=4 sw=4 expandtab: */
/*
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);
/* vi: set ts=4 sw=4 expandtab: */
/*
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;
}
/* vi: set ts=4 sw=4 expandtab: */
/*
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 */
/* vi: set ts=4 sw=4 expandtab: */
/*
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
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
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);
/* vi: set ts=4 sw=4 expandtab: */
/*
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);
}
/* vi: set ts=4 sw=4 expandtab: */
/*
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);
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
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 */
/* vi: set ts=4 sw=4 expandtab: */
/*
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);
}
}
/* vi: set ts=4 sw=4 expandtab: */
/*
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);
/* vi: set ts=4 sw=4 expandtab: */
...@@ -160,8 +160,6 @@ main(int argc, char *argv[]) ...@@ -160,8 +160,6 @@ main(int argc, char *argv[])
printf("This system is running %s\n", printf("This system is running %s\n",
#if __AIX__ #if __AIX__
"AIX" "AIX"
#elif __AMIGA__
"AmigaOS"
#elif __BEOS__ #elif __BEOS__
"BeOS" "BeOS"
#elif __BSDI__ #elif __BSDI__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment