19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Written by Darrell Walisser <dwaliss1@purdue.edu> 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Implementation notes ---------------------------------------------------------------------- 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall A bit on GWorlds in VRAM from technote 1182: 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall There are two important things to note about GWorld's allocated in 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall VRAM. First, the base address retrieved through GetPixBaseAddr or 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall read directly from the PixMap structure can become invalid anytime 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall memory is allocated in VRAM. This can occur either by explicit 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall allocations, such as calls to NewGWorld, or by implicit ones, such as 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall those associated with the internal texture allocation of OpenGL. The 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall stored pixel images themselves will still be valid but may have been 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall moved in VRAM, thus rendering any stored base addresses invalid. 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should never store an image's base address for longer than is 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall necessary and especially never across calls to NewGWorld or 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texture-creation routines. 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Secondly, an offscreen pixel image allocated in VRAM can be 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall purged at system task time by the display driver. This means any 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall time your application yields time such by calling WaitNextEvent or 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SystemTask you can lose your VRAM GWorld contents. While this 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall happens infrequently, usually associated with display resolution or 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pixel depth changes you must code for this eventuality. This purge 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall can occur whether or not the GWorld is locked or not. A return value 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall of false from LockPixels, a NULL return value from GetPixBaseAddr 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall or NULL in the baseAddr field of the PixMap mean that the pixel 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall image has been purged. To reallocate it you can either call 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UpdateGWorld or Dispose your current GWorld through 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposeGWorld and reallocate it via NewGWorld. Either way you must 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall then rebuild the pixel image. 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall------------------------------------------------------------------------------------ 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Currently, I don't account for (1). In my testing, NewGWorld never invalidated 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall other existing GWorlds in VRAM. However, I do have protection for (2). 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Namely, I am using GetOSEvent() instead of WaitNextEvent() so that there are no 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall context switches (the app hogs the CPU). Eventually a book-keeping system should 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall be coded to take care of (1) and (2). 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall------------------------------------------------------------------------------------ 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall System requirements (* denotes optional): 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1. DrawSprocket 1.7.3 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2. *MacOS 9 or later (but *not* Mac OS X) for hardware accelerated blit / fill 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3. *May also require certain graphics hardware for (2). I trust that all Apple OEM 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hardware will work. Third party accelerators may work if they have QuickDraw 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall acceleration in the drivers and the drivers have been updated for OS 9. The current 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Voodoo 3 drivers (1.0b12) do not work. 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Coding suggestions: 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1. Use SDL_UpdateRects ! 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall If no QuickDraw acceleration is present, double-buffered surfaces will use a back buffer 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall in System memory. I recommend you use SDL_UpdateRects with double-buffered surfaces 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for best performance on these cards, since the overhead is nearly zero for VRAM back buffer. 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2. Load most-resident surfaces first. 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall If you fill up VRAM or AGP memory, there is no contingency for purging to make room for the next one. 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Therefore, you should load the surfaces you plan to use the most frequently first. 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sooner or later, I will code LRU replacement to help this. 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall TODO: 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Some kind of posterized mode for resolutions < 640x480. 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Window support / fullscreen toggle. 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Figure out how much VRAM is available. Put in video->info->video_mem. 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Track VRAM usage. 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall BUGS: 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall I can't create a hardware surface the same size as the screen?! How to fix? 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall COMPILE OPTIONS: 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSP_TRY_CC_AND_AA - Define if you want to try HWA color-key and alpha blitters 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HW color-key blitting gives substantial improvements, 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but hw alpha is neck-and-neck with SDL's soft bitter. 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSP_NO_SYNC_VBL - Define for HWA double-buffered surfaces: don't sync 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pseudo-flip to monitor redraw. 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSP_NO_SYNC_OPENGL - Define for OpenGL surfaces: don't sync buffer swap. Synching buffer 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall swap may result in reduced performance, but can eliminate some 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall tearing artifacts. 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CHANGELOG: 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 09/17/00 Lots of little tweaks. Build modelist in reverse order so largest contexts 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall list first. Compared various methods with ROM methods and fixed rez switch 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall crashing bug in GL Tron. (Woohoo!) 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define DSP_TRY_CC_AND_AA 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* #define DSP_NO_SYNC_VBL */ 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define DSP_NO_SYNC_OPENGL 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if defined(__APPLE__) && defined(__MACH__) 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <Carbon/Carbon.h> 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <DrawSprocket/DrawSprocket.h> 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <Carbon.h> 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <DrawSprocket.h> 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <LowMem.h> 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <Gestalt.h> 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <Devices.h> 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <DiskInit.h> 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <QDOffscreen.h> 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <DrawSprocket.h> 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_video.h" 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_syswm.h" 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_sysvideo.h" 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_blit.h" 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_pixels_c.h" 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_dspvideo.h" 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../maccommon/SDL_macgl_c.h" 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../maccommon/SDL_macwm_c.h" 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../maccommon/SDL_macmouse_c.h" 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../maccommon/SDL_macevents_c.h" 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Initialization/Query functions */ 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat); 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Surface *DSp_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_SetColors(_THIS, int firstcolor, int ncolors, 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Color *colors); 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_CreatePalette(_THIS); 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_DestroyPalette(_THIS); 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_VideoQuit(_THIS); 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_GetMainDevice (_THIS, GDHandle *device); 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_IsHWAvailable (_THIS, SDL_PixelFormat *vformat); 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_DSpUpdate(_THIS, int numrects, SDL_Rect *sdl_rects); 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect *sdl_rects); 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Hardware surface functions */ 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_SetHWAlpha(_THIS, SDL_Surface *surface, UInt8 alpha); 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key); 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_NewHWSurface(_THIS, CGrafPtr *port, int depth, int width, int height); 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_AllocHWSurface(_THIS, SDL_Surface *surface); 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_LockHWSurface(_THIS, SDL_Surface *surface); 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_UnlockHWSurface(_THIS, SDL_Surface *surface); 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_FreeHWSurface(_THIS, SDL_Surface *surface); 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_FlipHWSurface(_THIS, SDL_Surface *surface); 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dest); 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *dst, SDL_Rect *dstrect); 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color); 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static void DSp_GL_SwapBuffers (_THIS); 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if ! TARGET_API_MAC_CARBON 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #define GetPortPixRowBytes(x) ( (*(x->portPixMap))->rowBytes ) 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #define GetGDevPixMap(x) ((**(x)).gdPMap) 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #define GetPortPixMap(x) ((*(x)).portPixMap) 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #define GetPixDepth(y) ((**(y)).pixelSize) 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //#define GetPixRowBytes(y) ((**(y)).rowBytes) 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //#define GetPixBaseAddr(y) ((**(y)).baseAddr) 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #define GetPixCTab(y) ((**(y)).pmTable) 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #define GetPortBitMapForCopyBits(x) (&(((GrafPtr)(x))->portBits)) 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #define GetPortPixRowBytes(x) (GetPixRowBytes(GetPortPixMap(x)) ) 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #define GetGDevPixMap(x) ((**(x)).gdPMap) 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct private_hwdata { 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GWorldPtr offscreen; // offscreen gworld in VRAM or AGP 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #ifdef DSP_TRY_CC_AND_AA 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GWorldPtr mask; // transparent mask 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBColor alpha; // alpha color 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBColor trans; // transparent color 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} private_hwdata; 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef private_hwdata private_swdata ; /* have same fields */ 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Macintosh toolbox driver bootstrap functions */ 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_Available(void) 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check for DrawSprocket */ 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if ! TARGET_API_MAC_OSX 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* This check is only meaningful if you weak-link DrawSprocketLib */ 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return ((Ptr)DSpStartup != (Ptr)kUnresolvedCFragSymbolAddress); 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 1; // DrawSprocket.framework doesn't have it all, but it's there 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_DeleteDevice(SDL_VideoDevice *device) 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* -dw- taking no chances with null pointers */ 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (device) { 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (device->hidden) { 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (device->hidden->dspinfo) 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(device->hidden->dspinfo); 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(device->hidden); 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(device); 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_VideoDevice *DSp_CreateDevice(int devindex) 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice *device; 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Initialize all variables that we clean on shutdown */ 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( device ) { 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(device, 0, sizeof (*device)); 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->hidden = (struct SDL_PrivateVideoData *) 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_malloc((sizeof *device->hidden)); 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (device->hidden) 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(device->hidden, 0, sizeof ( *(device->hidden) ) ); 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (device == NULL) || (device->hidden == NULL) ) { 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( device ) { 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (device->hidden) 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(device->hidden); 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(device); 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(NULL); 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Allocate DrawSprocket information */ 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->hidden->dspinfo = (struct DSpInfo *)SDL_malloc( 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (sizeof *device->hidden->dspinfo)); 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( device->hidden->dspinfo == NULL ) { 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(device->hidden); 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(device); 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(device->hidden->dspinfo, 0, (sizeof *device->hidden->dspinfo)); 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the function pointers */ 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->VideoInit = DSp_VideoInit; 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->ListModes = DSp_ListModes; 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetVideoMode = DSp_SetVideoMode; 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetColors = DSp_SetColors; 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->UpdateRects = NULL; 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->VideoQuit = DSp_VideoQuit; 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->AllocHWSurface = DSp_AllocHWSurface; 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->CheckHWBlit = NULL; 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FillHWRect = NULL; 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetHWColorKey = NULL; 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetHWAlpha = NULL; 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->LockHWSurface = DSp_LockHWSurface; 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->UnlockHWSurface = DSp_UnlockHWSurface; 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FlipHWSurface = DSp_FlipHWSurface; 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FreeHWSurface = DSp_FreeHWSurface; 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_MACCLASSIC_GAMMA_SUPPORT 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetGammaRamp = Mac_SetGammaRamp; 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GetGammaRamp = Mac_GetGammaRamp; 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GL_MakeCurrent = Mac_GL_MakeCurrent; 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GL_SwapBuffers = DSp_GL_SwapBuffers; 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GL_LoadLibrary = Mac_GL_LoadLibrary; 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GL_GetProcAddress = Mac_GL_GetProcAddress; 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetCaption = NULL; 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->SetIcon = NULL; 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->IconifyWindow = NULL; 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GrabInput = NULL; 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GetWMInfo = NULL; 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->FreeWMCursor = Mac_FreeWMCursor; 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->CreateWMCursor = Mac_CreateWMCursor; 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->ShowWMCursor = Mac_ShowWMCursor; 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->WarpWMCursor = Mac_WarpWMCursor; 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->InitOSKeymap = Mac_InitOSKeymap; 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->PumpEvents = Mac_PumpEvents; 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->GrabInput = NULL; 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->CheckMouseMode = NULL; 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device->free = DSp_DeleteDevice; 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return device; 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallVideoBootStrap DSp_bootstrap = { 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall "DSp", "MacOS DrawSprocket", 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_Available, DSp_CreateDevice 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Use DSp/Display Manager to build mode list for given screen */ 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Rect** DSp_BuildModeList (const GDHandle gDevice, int *displayWidth, int *displayHeight) 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContextAttributes attributes; 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContextReference context; 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisplayIDType displayID; 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect temp_list [16]; 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect **mode_list; 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int width, height, i, j; 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if TARGET_API_MAC_OSX 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall displayID = 0; 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #else 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Ask Display Manager for integer id of screen device */ 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DMGetDisplayIDByGDevice (gDevice, &displayID, SDL_TRUE) != noErr ) { 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get the first possible DSp context on this device */ 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSpGetFirstContext (displayID, &context) != noErr ) { 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSpContext_GetAttributes (context, &attributes) != noErr ) 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *displayWidth = attributes.displayWidth; 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *displayHeight = attributes.displayHeight; 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i = 0; i < SDL_arraysize(temp_list); i++ ) { 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall width = attributes.displayWidth; 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall height = attributes.displayHeight; 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall temp_list [i].x = 0 | attributes.displayBestDepth; 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall temp_list [i].y = 0; 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall temp_list [i].w = width; 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall temp_list [i].h = height; 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* DSp will report many different contexts with the same width and height. */ 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* They will differ in bit depth and refresh rate. */ 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We will ignore them until we reach one with a different width/height */ 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* When there are no more contexts to look at, we will quit building the list*/ 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( width == attributes.displayWidth && height == attributes.displayHeight ) { 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus err = DSpGetNextContext (context, &context); 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (err != noErr) 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (err == kDSpContextNotFoundErr) 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto done; 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSpContext_GetAttributes (context, &attributes) != noErr ) 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall temp_list [i].x |= attributes.displayBestDepth; 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halldone: 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall i++; /* i was not incremented before kicking out of the loop */ 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode_list = (SDL_Rect**) SDL_malloc (sizeof (SDL_Rect*) * (i+1)); 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (mode_list) { 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* -dw- new stuff: build in reverse order so largest sizes list first */ 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (j = i-1; j >= 0; j--) { 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode_list [j] = (SDL_Rect*) SDL_malloc (sizeof (SDL_Rect)); 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (mode_list [j]) 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memcpy (mode_list [j], &(temp_list [j]), sizeof (SDL_Rect)); 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else { 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory (); 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode_list [i] = NULL; /* append null to the end */ 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else { 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory (); 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return mode_list; 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_IsHWAvailable (_THIS, SDL_PixelFormat *vformat) 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall VRAM GWorlds are only available on OS 9 or later. 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Even with OS 9, some display drivers won't support it, 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall so we create a test GWorld and check for errors. 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall long versionSystem; 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_vram_available = SDL_FALSE; 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_agp_available = SDL_FALSE; 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Gestalt ('sysv', &versionSystem); 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (0x00000860 < (versionSystem & 0x0000FFFF)) { 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GWorldPtr offscreen; 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus err; 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Rect bounds; 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetRect (&bounds, 0, 0, 320, 240); 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if useDistantHdwrMem && useLocalHdwrMem 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall err = NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, SDL_Display, useDistantHdwrMem | noNewDevice); 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (err == noErr) { 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_vram_available = SDL_TRUE; 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposeGWorld (offscreen); 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall err = NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, SDL_Display, useLocalHdwrMem | noNewDevice); 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (err == noErr) { 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposeGWorld (offscreen); 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_agp_available = SDL_TRUE; 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_GetMainDevice (_THIS, GDHandle *device) 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if TARGET_API_MAC_OSX 4629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* DSpUserSelectContext not available on OS X */ 4639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *device = GetMainDevice(); 4649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 4659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 4669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContextAttributes attrib; 4689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContextReference context; 4699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisplayIDType display_id; 4709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GDHandle main_device; 4719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GDHandle device_list; 4729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall device_list = GetDeviceList (); 4749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall main_device = GetMainDevice (); 4759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Quick check to avoid slower method when only one display exists */ 4779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (**device_list).gdNextGD == NULL ) { 4789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *device = main_device; 4799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 4809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset (&attrib, 0, sizeof (DSpContextAttributes)); 4839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* These attributes are hopefully supported on all devices...*/ 4859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.displayWidth = 640; 4869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.displayHeight = 480; 4879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.displayBestDepth = 8; 4889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.backBufferBestDepth = 8; 4899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.displayDepthMask = kDSpDepthMask_All; 4909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.backBufferDepthMask = kDSpDepthMask_All; 4919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.colorNeeds = kDSpColorNeeds_Require; 4929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.pageCount = 1; 4939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (noErr != DMGetDisplayIDByGDevice (main_device, &display_id, SDL_FALSE)) { 4959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("Display Manager couldn't associate GDevice with a Display ID"); 4969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 4979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Put up dialog on main display to select which display to use */ 5009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (noErr != DSpUserSelectContext (&attrib, display_id, NULL, &context)) { 5019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket couldn't create a context"); 5029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 5039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (noErr != DSpContext_GetDisplayID (context, &display_id)) { 5069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket couldn't get display ID"); 5079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 5089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (noErr != DMGetGDeviceByDisplayID (display_id, &main_device, SDL_FALSE)) { 5119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("Display Manager couldn't associate Display ID with GDevice"); 5129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 5139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *device = main_device; 5169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (0); 5179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 5189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat) 5219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NumVersion dsp_version = { 0x01, 0x00, 0x00, 0x00 }; 5239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if UNIVERSAL_INTERFACES_VERSION > 0x0320 5259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_version = DSpGetVersion (); 5269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 5279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (dsp_version.majorRev == 1 && dsp_version.minorAndBugRev < 0x73) || 5299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (dsp_version.majorRev < 1) ) { 5309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* StandardAlert (kAlertStopAlert, "\pError!", 5329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall "\pI need DrawSprocket 1.7.3 or later!\n" 5339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall "You can find a newer version at http://www.apple.com/swupdates.", 5349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL, NULL); 5359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 5369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket version is too old. Need 1.7.3 or later."); 5379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 5389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSpStartup () != noErr ) { 5419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket couldn't startup"); 5429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 5439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Start DSpintosh events */ 5469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mac_InitEvents(this); 5479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get a handle to the main monitor, or choose one on multiple monitor setups */ 5499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSp_GetMainDevice(this, &SDL_Display) < 0) 5509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 5519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Determine pixel format */ 5539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vformat->BitsPerPixel = GetPixDepth ( (**SDL_Display).gdPMap ); 5549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_old_depth = vformat->BitsPerPixel; 5559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (vformat->BitsPerPixel) { 5579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 16: 5589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vformat->Rmask = 0x00007c00; 5599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vformat->Gmask = 0x000003e0; 5609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall vformat->Bmask = 0x0000001f; 5619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 5629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 5639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 5649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSp_CreatePalette (this) < 0 ) { 5679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("Could not create palette"); 5689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 5699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get a list of available fullscreen modes */ 5729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_modelist = DSp_BuildModeList (SDL_Display, 5739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &this->info.current_w, &this->info.current_h); 5749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (SDL_modelist == NULL) { 5759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket could not build a mode list"); 5769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 5779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check for VRAM and AGP GWorlds for HW Blitting */ 5809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_IsHWAvailable (this, vformat); 5819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.wm_available = 0; 5839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (dsp_vram_available || dsp_agp_available) { 5859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.hw_available = SDL_TRUE; 5879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->CheckHWBlit = DSp_CheckHWBlit; 5899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw = SDL_TRUE; 5909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->FillHWRect = DSp_FillHWRect; 5929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_fill = SDL_TRUE; 5939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #ifdef DSP_TRY_CC_AND_AA 5959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->SetHWColorKey = DSp_SetHWColorKey; 5969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw_CC = SDL_TRUE; 5979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->SetHWAlpha = DSp_SetHWAlpha; 5999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw_A = SDL_TRUE; 6009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 6019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 6059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) 6089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static SDL_Rect *dsp_modes[16]; 6109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i = 0, j = 0; 6119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( format->BitsPerPixel == 0 ) 6139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return ( (SDL_Rect**) NULL ); 6149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while (SDL_modelist[i] != NULL) { 6169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (SDL_modelist[i]->x & format->BitsPerPixel) { 6189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_modes[j] = SDL_modelist[i]; 6199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall j++; 6209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall i++; 6229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_modes[j] = NULL; 6259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return dsp_modes; 6279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Various screen update functions available */ 6309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); 6319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if ! TARGET_API_MAC_OSX 6339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic volatile unsigned int retrace_count = 0; /* -dw- need volatile because it updates asychronously */ 6359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallBoolean DSp_VBLProc ( DSpContextReference context, void *ref_con ) 6379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall retrace_count++; 6399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 1; /* Darrell, is this right? */ 6419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_SetHWError (OSStatus err, int is_agp) 6449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall char message[1024]; 6469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const char *fmt, *mem; 6479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( is_agp ) { 6499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mem = "AGP Memory"; 6509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 6519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mem = "VRAM"; 6529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(err) { 6549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case memFullErr: 6559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fmt = "Hardware surface possible but not enough %s available"; 6569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case cDepthErr: 6589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fmt = "Hardware surface possible but invalid color depth"; 6599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 6619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fmt = "Hardware surface could not be allocated in %s - unknown error"; 6629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_snprintf(message, SDL_arraysize(message), fmt, mem); 6659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError(message); 6669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif // TARGET_API_MAC_OSX 6689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* put up a dialog to verify display change */ 6709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_ConfirmSwitch () { 6719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* resource id's for dialog */ 6739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const int rDialog = 1002; 6749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const int bCancel = 1; 6759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const int bOK = 2; 6769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DialogPtr dialog; 6789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus err; 6799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SInt32 response; 6809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DialogItemIndex item = 0; 6819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GrafPtr savePort; 6829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetPort (&savePort); 6849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dialog = GetNewDialog (rDialog, NULL, (WindowPtr) -1); 6869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (dialog == NULL) 6879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (0); 6889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if TARGET_API_MAC_CARBON 6909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPort (GetDialogPort(dialog)); 6919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 6929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPort ((WindowPtr) dialog); 6939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 6949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetDialogDefaultItem (dialog, bCancel); 6969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetDialogCancelItem (dialog, bCancel); 6979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetEventMask (everyEvent); 6999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FlushEvents (everyEvent, 0); 7009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* On MacOS 8.5 or later, we can make the dialog go away after 15 seconds */ 7029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* This is good since it's possible user can't even see the dialog! */ 7039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Requires linking to DialogsLib */ 7049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall err = Gestalt(gestaltSystemVersion,&response); 7059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (err == noErr && response >= 0x00000850) { 7069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetDialogTimeout(dialog, bCancel, 15); 7079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall do { 7109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ModalDialog ( NULL, &item ); 7129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } while ( item != bCancel && item != bOK && err != noErr); 7149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposeDialog (dialog); 7179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPort (savePort); 7189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetEventMask(everyEvent - autoKeyMask); 7209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FlushEvents(everyEvent, 0); 7219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (item - 1); 7239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_UnsetVideoMode(_THIS, SDL_Surface *current) 7269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( current->flags & SDL_OPENGL ) { 7309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mac_GL_Quit (this); 7319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (dsp_context != NULL) { 7349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GWorldPtr front; 7369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_GetFrontBuffer (dsp_context, &front); 7379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (front != dsp_back_buffer) 7399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposeGWorld (dsp_back_buffer); 7409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (current->hwdata) 7429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(current->hwdata); 7439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_SetState (dsp_context, kDSpContextState_Inactive ); 7459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_Release (dsp_context); 7469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_context = NULL; 7489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (SDL_Window != NULL) { 7519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposeWindow (SDL_Window); 7529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Window = NULL; 7539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pixels = NULL; 7569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags = 0; 7579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Surface *DSp_SetVideoMode(_THIS, 7609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *current, int width, int height, int bpp, Uint32 flags) 7619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if !TARGET_API_MAC_OSX 7649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisplayIDType display_id; 7659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Fixed freq; 7669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 7679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContextAttributes attrib; 7689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus err; 7699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UInt32 rmask = 0, gmask = 0, bmask = 0; 7709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int page_count; 7729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int double_buf; 7739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int hw_surface; 7749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int use_dsp_back_buffer; 7759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_UnsetVideoMode (this, current); 7779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bpp != dsp_old_depth) 7799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_DestroyPalette (this); 7809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall double_buf = (flags & SDL_DOUBLEBUF) != 0; 7829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hw_surface = (flags & SDL_HWSURFACE) != 0; 7839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall use_dsp_back_buffer = !dsp_vram_available || !hw_surface ; 7849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_FULLSCREEN; 7869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallrebuild: 7889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( double_buf && use_dsp_back_buffer ) { 7909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall page_count = 2; 7919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 7929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall page_count = 1; 7939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset (&attrib, 0, sizeof (DSpContextAttributes)); 7969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.displayWidth = width; 7979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.displayHeight = height; 7989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.displayBestDepth = bpp; 7999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.backBufferBestDepth = bpp; 8009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.displayDepthMask = kDSpDepthMask_All; 8019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.backBufferDepthMask = kDSpDepthMask_All; 8029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.colorNeeds = kDSpColorNeeds_Require; 8039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.colorTable = 0; 8049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall attrib.pageCount = page_count; 8059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if TARGET_API_MAC_OSX || UNIVERSAL_INTERFACES_VERSION == 0x0320 8069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSpFindBestContext (&attrib, &dsp_context) != noErr ) { 8089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket couldn't find a context"); 8099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 8109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #else 8139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( noErr != DMGetDisplayIDByGDevice (SDL_Display, &display_id, SDL_FALSE) ) { 8149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("Display Manager couldn't associate GDevice with display_id"); 8159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 8169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSpFindBestContextOnDisplayID(&attrib, &dsp_context, display_id) != noErr ) { 8189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket couldn't find a suitable context on given display"); 8199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 8209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 8239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSpContext_Reserve (dsp_context, &attrib) != noErr ) { 8249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket couldn't get the needed resources to build the display"); 8259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 8269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (err = DSpContext_SetState (dsp_context, kDSpContextState_Active)) != noErr ) { 8299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (err == kDSpConfirmSwitchWarning) { 8319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! DSp_ConfirmSwitch () ) { 8339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_Release (dsp_context); 8359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dsp_context = NULL; 8369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("User cancelled display switch"); 8379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 8389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 8409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Have to reactivate context. Why? */ 8419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_SetState (dsp_context, kDSpContextState_Active); 8429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else { 8459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DrawSprocket couldn't activate the context"); 8469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 8479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bpp != dsp_old_depth) { 8529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_CreatePalette (this); 8549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* update format if display depth changed */ 8569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bpp == 16) { 8579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rmask = 0x00007c00; 8599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall gmask = 0x000003e0; 8609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bmask = 0x0000001f; 8619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! SDL_ReallocFormat (current, bpp, rmask, gmask, bmask, 0 ) ) { 8639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("Could not reallocate video format."); 8659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(NULL); 8669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!double_buf) { 8709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* single-buffer context */ 8729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_GetFrontBuffer (dsp_context, &dsp_back_buffer); 8739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata)); 8759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (current ->hwdata == NULL) { 8769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory (); 8779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 8789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->hwdata->offscreen = dsp_back_buffer; 8809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_HWSURFACE; 8819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->UpdateRects = DSp_DirectUpdate; 8829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if ( use_dsp_back_buffer ) { 8849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_GetBackBuffer (dsp_context, kDSpBufferKind_Normal, &dsp_back_buffer); 8869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_DOUBLEBUF | SDL_SWSURFACE; /* only front buffer is in VRAM */ 8889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->UpdateRects = DSp_DSpUpdate; 8899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if ( DSp_NewHWSurface(this, &dsp_back_buffer, bpp, width-1, height-1) == 0 ) { 8919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata)); 8939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (current ->hwdata == NULL) { 8949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory (); 8959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 8969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset (current->hwdata, 0, sizeof (private_hwdata)); 8999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->hwdata->offscreen = dsp_back_buffer; 9009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE; 9019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->UpdateRects = DSp_DirectUpdate; /* hardware doesn't do update rects, must be page-flipped */ 9029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else { 9049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_Release (dsp_context); 9069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall use_dsp_back_buffer = SDL_TRUE; 9079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto rebuild; 9089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pitch = GetPortPixRowBytes(dsp_back_buffer) & 0x3FFF; 9119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer)); 9129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->w = width; 9149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->h = height; 9159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if ! TARGET_API_MAC_OSX 9179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (use_dsp_back_buffer) { 9199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_GetMonitorFrequency (dsp_context, &freq); 9219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_SetMaxFrameRate (dsp_context, freq >> 16); 9229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (current->flags & SDL_HWSURFACE) || (current->flags & SDL_OPENGL) ) 9269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_SetVBLProc (dsp_context, DSp_VBLProc, NULL); 9279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 9289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (bpp == 8) 9309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_HWPALETTE; 9319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (flags & SDL_OPENGL) { 9339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Rect rect; 9359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBColor rgb = { 0.0, 0.0, 0.0 }; 9369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GrafPtr save_port; 9379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetRect (&rect, 0, 0, width, height); 9399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Window = NewCWindow(nil, &( (**SDL_Display).gdRect), "\p", SDL_TRUE, plainDBox, (WindowPtr)-1, SDL_FALSE, 0); 9409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (SDL_Window == NULL) { 9429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DSp_SetVideoMode : OpenGL window could not be created."); 9449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 9459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set window color to black to avoid white flash*/ 9489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetPort (&save_port); 9499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if TARGET_API_MAC_CARBON 9509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPort (GetWindowPort(SDL_Window)); 9519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 9529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPort (SDL_Window); 9539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 9549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBForeColor (&rgb); 9559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PaintRect (&rect); 9569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPort (save_port); 9579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPortWindowPort (SDL_Window); 9599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SelectWindow (SDL_Window); 9609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( Mac_GL_Init (this) < 0 ) { 9629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("DSp_SetVideoMode : could not create OpenGL context."); 9649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return NULL; 9659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall current->flags |= SDL_OPENGL; 9689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return current; 9719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 9729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef DSP_TRY_CC_AND_AA 9749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_MakeHWMask (_THIS, SDL_Surface *surface) 9769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 9779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GDHandle save_device; 9789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CGrafPtr save_port; 9799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GWorldPtr temp; 9809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBColor black = { 0, 0, 0 }; 9819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF }; 9829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Rect rect; 9839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint32 depth = GetPixDepth ( GetGDevPixMap (SDL_Display) ); 9859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetRect (&rect, 0, 0, surface->w, surface->h); 9879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( noErr != NewGWorld (&(surface->hwdata->mask), depth, &rect, 0, SDL_Display, 0 ) < 0 ) { 9899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory (); 9919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 9929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( noErr != NewGWorld (&temp, depth, &rect, 0 , SDL_Display, 0 ) ) { 9959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory (); 9979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 9989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetGWorld (&save_port, &save_device); 10029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (surface->hwdata->mask, SDL_Display); 10039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBForeColor (&white); 10059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PaintRect (&rect); 10069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBBackColor (&(surface->hwdata->trans)); 10089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CopyBits ( GetPortBitMapForCopyBits(surface->hwdata->offscreen), 10109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetPortBitMapForCopyBits(surface->hwdata->mask), 10119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &rect, &rect, transparent, NULL ); 10129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (surface->hwdata->mask, SDL_Display); 10149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (save_port, save_device); 10159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (0); 10169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 10179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_SetHWAlpha(_THIS, SDL_Surface *surface, UInt8 alpha) 10199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 10209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->alpha.red = (alpha / 255.0) * 65535; 10219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->alpha.blue = (alpha / 255.0) * 65535; 10229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->alpha.green = (alpha / 255.0) * 65535; 10239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->flags |= SDL_SRCALPHA; 10259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->flags & SDL_SRCCOLORKEY) { 10279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(DSp_MakeHWMask (this, surface)); 10289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 10309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 10319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key) 10339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 10349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CGrafPtr save_port; 10359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GDHandle save_device; 10369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetGWorld (&save_port, &save_device); 10389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (surface->hwdata->offscreen, NULL); 10399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Index2Color (key, &(surface->hwdata->trans)); 10419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->flags |= SDL_SRCCOLORKEY; 10429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (save_port, save_device); 10449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( surface->flags & SDL_SRCALPHA ) { 10469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(DSp_MakeHWMask (this, surface)); 10479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 10499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 10509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* DSP_TRY_CC_AND_AA */ 10529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_NewHWSurface(_THIS, CGrafPtr *port, int depth, int width, int height) { 10549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus err; 10569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Rect bounds; 10579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetRect (&bounds, 0, 0, width, height); 10599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if useDistantHdwrMem && useLocalHdwrMem 10619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (dsp_vram_available) { 10629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* try VRAM */ 10639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall err = NewGWorld (port, depth, &bounds, 0 , SDL_Display, useDistantHdwrMem | noNewDevice ); 10649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (err != noErr) 10659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_SetHWError (err, SDL_FALSE); 10669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 10679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (0); 10689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (dsp_agp_available) { 10719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* try AGP */ 10729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall err = NewGWorld (port, depth, &bounds, 0 , SDL_Display, useLocalHdwrMem | noNewDevice ); 10739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (err != noErr) 10759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_SetHWError (err, SDL_TRUE); 10769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 10779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (0); 10789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 10809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 10829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 10839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_AllocHWSurface(_THIS, SDL_Surface *surface) 10859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 10869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GWorldPtr temp; 10879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( DSp_NewHWSurface (this, &temp, surface->format->BitsPerPixel, surface->w, surface->h) < 0 ) 10899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (-1); 10909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata)); 10929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata == NULL) { 10939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory (); 10949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 10959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset (surface->hwdata, 0, sizeof(private_hwdata)); 10989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->offscreen = temp; 10999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->pitch = GetPixRowBytes (GetPortPixMap (temp)) & 0x3FFF; 11009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->pixels = GetPixBaseAddr (GetPortPixMap (temp)); 11019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->flags |= SDL_HWSURFACE; 11029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef DSP_TRY_CC_AND_AA 11039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->flags |= SDL_HWACCEL; 11049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 11059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 11069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 11079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_FreeHWSurface(_THIS, SDL_Surface *surface) 11099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 11109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata->offscreen != NULL) 11119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposeGWorld (surface->hwdata->offscreen); 11129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(surface->hwdata); 11139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->pixels = NULL; 11159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 11169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dest) 11189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 11199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int accelerated; 11209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set initial acceleration on */ 11229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->flags |= SDL_HWACCEL; 11239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the surface attributes */ 11259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 11269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! this->info.blit_hw_A ) { 11279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->flags &= ~SDL_HWACCEL; 11289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) { 11319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! this->info.blit_hw_CC ) { 11329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->flags &= ~SDL_HWACCEL; 11339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check to see if final surface blit is accelerated */ 11379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall accelerated = !!(src->flags & SDL_HWACCEL); 11389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( accelerated ) { 11399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->map->hw_blit = DSp_HWAccelBlit; 11409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(accelerated); 11429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 11439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, 11459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *dst, SDL_Rect *dstrect) 11469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 11479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CGrafPtr save_port; 11489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GDHandle save_device; 11499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Rect src_rect, dst_rect; 11509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBColor black = { 0, 0, 0 }; 11519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF }; 11529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef DSP_TRY_CC_AND_AA 11549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UInt32 mode; 11559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 11569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetRect (&src_rect, srcrect->x, srcrect->y, srcrect->x + srcrect->w, srcrect->y + srcrect->h); 11589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetRect (&dst_rect, dstrect->x, dstrect->y, dstrect->x + dstrect->w, dstrect->y + dstrect->h); 11599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetGWorld (&save_port, &save_device); 11619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (dst->hwdata->offscreen, NULL); 11629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBForeColor (&black); 11649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBBackColor (&white); 11659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef DSP_TRY_CC_AND_AA 11679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (src->flags & SDL_SRCCOLORKEY) && 11699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (src->flags & SDL_SRCALPHA) ) { 11709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OpColor (&(src->hwdata->alpha)); 11729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CopyDeepMask ( GetPortBitMapForCopyBits(src->hwdata->offscreen), 11749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetPortBitMapForCopyBits(src->hwdata->mask), 11759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetPortBitMapForCopyBits(dst->hwdata->offscreen), 11769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &src_rect, &src_rect, &dst_rect, 11779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall blend, 11789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL ); 11799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else { 11819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( src->flags & SDL_SRCCOLORKEY) { 11839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBBackColor (&(src->hwdata->trans) ); 11849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode = transparent; 11859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if (src->flags & SDL_SRCALPHA) { 11879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OpColor (&(src->hwdata->alpha)); 11899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode = blend; 11909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else { 11929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode = srcCopy; 11949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 11959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 11969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CopyBits ( GetPortBitMapForCopyBits(src->hwdata->offscreen), 11979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetPortBitMapForCopyBits(dst->hwdata->offscreen), 11989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &src_rect, &dst_rect, mode, NULL ); 11999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 12019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CopyBits ( &(((GrafPtr)(src->hwdata->offscreen))->portBits), 12039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &(((GrafPtr)(dst->hwdata->offscreen))->portBits), 12049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &src_rect, &dst_rect, srcCopy, NULL ); 12059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* DSP_TRY_CC_AND_AA */ 12079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (save_port, save_device); 12099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 12119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 12129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) 12149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 12159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CGrafPtr save_port; 12169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GDHandle save_device; 12179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Rect fill_rect; 12189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBColor rgb; 12199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetRect (&fill_rect, rect->x, rect->y, rect->x + rect->w, rect->y + rect->h); 12219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetGWorld (&save_port, &save_device); 12239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (dst->hwdata->offscreen, NULL); 12249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Index2Color (color, &rgb); 12269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RGBForeColor (&rgb); 12289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PaintRect (&fill_rect); 12299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGWorld (save_port, save_device); 12319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 12339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 12349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_FlipHWSurface(_THIS, SDL_Surface *surface) 12369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 12379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (surface->flags & SDL_HWSURFACE) ) { 12389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CGrafPtr dsp_front_buffer, save_port; 12399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Rect rect; 12409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if ! TARGET_API_MAC_OSX 12429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall unsigned int old_count; 12439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 12449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* pseudo page flipping for VRAM back buffer*/ 12469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_GetFrontBuffer (dsp_context, &dsp_front_buffer); 12479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetRect (&rect, 0, 0, surface->w-1, surface->h-1); 12489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetPort ((GrafPtr *)&save_port); 12509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPort ((GrafPtr)dsp_front_buffer); 12519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* wait for retrace */ 12539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* I have tried doing the swap in interrupt routine (VBL Proc) to do */ 12549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* it asynchronously, but apparently CopyBits isn't interrupt safe */ 12559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if ! TARGET_API_MAC_OSX 12579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #ifndef DSP_NO_SYNC_VBL 12589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall old_count = retrace_count; 12599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while (old_count == retrace_count) 12609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ; 12619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 12629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 12639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CopyBits ( GetPortBitMapForCopyBits(dsp_back_buffer), 12659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GetPortBitMapForCopyBits(dsp_front_buffer), 12669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &rect, &rect, srcCopy, NULL ); 12679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetPort ((GrafPtr)save_port); 12699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 12719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* not really page flipping at all: DSp just blits the dirty rectangles from DSp_UpdateRects */ 12729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Boolean busy_flag; 12739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_SwapBuffers (dsp_context, NULL, &busy_flag); /* this waits for VBL */ 12749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_GetBackBuffer (dsp_context, kDSpBufferKind_Normal, &dsp_back_buffer); 12759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->pixels = GetPixBaseAddr( GetPortPixMap(dsp_back_buffer) ); 12769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 12779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 12789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 12799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_LockHWSurface(_THIS, SDL_Surface *surface) 12819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 12829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( LockPixels (GetGWorldPixMap (surface->hwdata->offscreen)) ) 12839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 12849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 12859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 12869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 12879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_UnlockHWSurface(_THIS, SDL_Surface *surface) 12899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 12909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UnlockPixels (GetGWorldPixMap (surface->hwdata->offscreen)); 12919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 12929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect *sdl_rects) 12949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 12959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 12969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 12979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 12989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_DSpUpdate(_THIS, int numrects, SDL_Rect *sdl_rects) 12999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 13009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if ! TARGET_API_MAC_OSX /* Unsupported DSp in here */ 13019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 13029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Rect rect; 13039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i = 0; i < numrects; i++) { 13059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect.top = sdl_rects[i].y; 13079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect.left = sdl_rects[i].x; 13089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect.bottom = sdl_rects[i].h + sdl_rects[i].y; 13099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rect.right = sdl_rects[i].w + sdl_rects[i].x; 13109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpContext_InvalBackBufferRect (dsp_context, &rect); 13129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 13149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 13159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_CreatePalette(_THIS) { 13179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Create our palette */ 13209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_CTab = (CTabHandle)NewHandle(sizeof(ColorSpec)*256 + 8); 13219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_CTab == nil ) { 13229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 13239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 13249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (**SDL_CTab).ctSeed = GetCTSeed(); 13269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (**SDL_CTab).ctFlags = 0; 13279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (**SDL_CTab).ctSize = 255; 13289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CTabChanged(SDL_CTab); 13299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit+pmTolerant, 0); 13309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 13329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 13339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_DestroyPalette(_THIS) { 13359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Free palette and restore original one */ 13379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_CTab != nil ) { 13389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposeHandle((Handle)SDL_CTab); 13399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_CTab = nil; 13409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_CPal != nil ) { 13429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposePalette(SDL_CPal); 13439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_CPal = nil; 13449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RestoreDeviceClut(SDL_Display); 13469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (0); 13489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 13499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DSp_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) 13519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 13529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CTabHandle cTab; 13539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 13559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cTab = SDL_CTab; 13579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Verify the range of colors */ 13599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (firstcolor+ncolors) > ((**cTab).ctSize+1) ) { 13609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 13619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the screen palette and update the display */ 13649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(i = 0; i < ncolors; i++) { 13659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int j = firstcolor + i; 13669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (**cTab).ctTable[j].value = j; 13679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (**cTab).ctTable[j].rgb.red = colors[i].r << 8 | colors[i].r; 13689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (**cTab).ctTable[j].rgb.green = colors[i].g << 8 | colors[i].g; 13699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b; 13709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetGDevice(SDL_Display); 13739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SetEntries(0, (**cTab).ctSize, (ColorSpec *)&(**cTab).ctTable); 13749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(1); 13769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 13779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DSp_VideoQuit(_THIS) 13799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 13809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 13819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Free current video mode */ 13839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_UnsetVideoMode(this, this->screen); 13849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Free Palette and restore original */ 13869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSp_DestroyPalette (this); 13879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_MACCLASSIC_GAMMA_SUPPORT 13899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Mac_QuitGamma(this); 13909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 13919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 13929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Free list of video modes */ 13939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_modelist != NULL ) { 13949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; SDL_modelist[i]; i++ ) { 13959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(SDL_modelist[i]); 13969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 13979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(SDL_modelist); 13989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_modelist = NULL; 13999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 14009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 14019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Unload DrawSprocket */ 14029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DSpShutdown (); 14039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 14049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 14059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 14069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 14079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* swap buffers with v-sync */ 14089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DSp_GL_SwapBuffers (_THIS) { 14099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 14109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #ifndef DSP_NO_SYNC_OPENGL 14119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 14129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall unsigned int old_count; 14139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 14149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall old_count = retrace_count; 14159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while (old_count == retrace_count) 14169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ; 14179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 14189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 14199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall aglSwapBuffers (glContext); 14209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 14219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 14229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 1423