diff options
Diffstat (limited to 'distrib/sdl-1.2.12/src/video/cybergfx')
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigaevents.c | 535 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigaevents_c.h | 29 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigamouse.c | 77 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigamouse_c.h | 32 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxaccel.c | 262 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxgl.c | 212 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxgl_c.h | 51 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgximage.c | 906 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgximage_c.h | 36 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxmodes.c | 316 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxmodes_c.h | 45 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxvideo.c | 1375 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxvideo.h | 172 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxwm.c | 63 | ||||
-rw-r--r-- | distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxwm_c.h | 33 |
15 files changed, 0 insertions, 4144 deletions
diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigaevents.c b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigaevents.c deleted file mode 100644 index 333d0fa..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigaevents.c +++ /dev/null @@ -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(); -} diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigaevents_c.h b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigaevents_c.h deleted file mode 100644 index 11b86b5..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigaevents_c.h +++ /dev/null @@ -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); - diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigamouse.c b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigamouse.c deleted file mode 100644 index 64940a8..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigamouse.c +++ /dev/null @@ -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) -{ -} diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigamouse_c.h b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigamouse_c.h deleted file mode 100644 index aad19b6..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_amigamouse_c.h +++ /dev/null @@ -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); diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxaccel.c b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxaccel.c deleted file mode 100644 index 24605e3..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxaccel.c +++ /dev/null @@ -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; -} diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxgl.c b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxgl.c deleted file mode 100644 index e19614b..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxgl.c +++ /dev/null @@ -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 */ - diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxgl_c.h b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxgl_c.h deleted file mode 100644 index 4c04f59..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxgl_c.h +++ /dev/null @@ -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 diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgximage.c b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgximage.c deleted file mode 100644 index 3e8938e..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgximage.c +++ /dev/null @@ -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); - } - -} diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgximage_c.h b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgximage_c.h deleted file mode 100644 index 30dc7a4..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgximage_c.h +++ /dev/null @@ -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); diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxmodes.c b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxmodes.c deleted file mode 100644 index fdf7dbd..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxmodes.c +++ /dev/null @@ -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); -} diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxmodes_c.h b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxmodes_c.h deleted file mode 100644 index 6c6f485..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxmodes_c.h +++ /dev/null @@ -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); diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxvideo.c b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxvideo.c deleted file mode 100644 index e306746..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxvideo.c +++ /dev/null @@ -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")); - -} - diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxvideo.h b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxvideo.h deleted file mode 100644 index 9ef76ea..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxvideo.h +++ /dev/null @@ -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 */ diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxwm.c b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxwm.c deleted file mode 100644 index 47a7d60..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxwm.c +++ /dev/null @@ -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); - } -} diff --git a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxwm_c.h b/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxwm_c.h deleted file mode 100644 index 35d1a61..0000000 --- a/distrib/sdl-1.2.12/src/video/cybergfx/SDL_cgxwm_c.h +++ /dev/null @@ -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); - |