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#include "SDL_video.h"
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_mouse.h"
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_sysvideo.h"
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_pixels_c.h"
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../../events/SDL_events_c.h"
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_dcvideo.h"
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_dcevents_c.h"
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_dcmouse_c.h"
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <dc/video.h>
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <dc/pvr.h>
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Initialization/Query functions */
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_VideoInit(_THIS, SDL_PixelFormat *vformat);
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Rect **DC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Surface *DC_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_VideoQuit(_THIS);
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Hardware surface functions */
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_AllocHWSurface(_THIS, SDL_Surface *surface);
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_LockHWSurface(_THIS, SDL_Surface *surface);
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_UnlockHWSurface(_THIS, SDL_Surface *surface);
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_FreeHWSurface(_THIS, SDL_Surface *surface);
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_FlipHWSurface(_THIS, SDL_Surface *surface);
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* etc. */
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* OpenGL */
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void *DC_GL_GetProcAddress(_THIS, const char *proc);
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_GL_LoadLibrary(_THIS, const char *path);
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_GL_SwapBuffers(_THIS);
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* DC driver bootstrap functions */
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_Available(void)
669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return 1;
689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_DeleteDevice(SDL_VideoDevice *device)
719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_free(device->hidden);
739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_free(device);
749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_VideoDevice *DC_CreateDevice(int devindex)
779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_VideoDevice *device;
799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Initialize all variables that we clean on shutdown */
819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if ( device ) {
839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		SDL_memset(device, 0, (sizeof *device));
849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		device->hidden = (struct SDL_PrivateVideoData *)
859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				SDL_malloc((sizeof *device->hidden));
869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if ( (device == NULL) || (device->hidden == NULL) ) {
889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		SDL_OutOfMemory();
899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		if ( device ) {
909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			SDL_free(device);
919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		return(0);
939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_memset(device->hidden, 0, (sizeof *device->hidden));
959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Set the function pointers */
979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->VideoInit = DC_VideoInit;
989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->ListModes = DC_ListModes;
999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->SetVideoMode = DC_SetVideoMode;
1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->CreateYUVOverlay = NULL;
1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->SetColors = DC_SetColors;
1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->UpdateRects = DC_UpdateRects;
1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->VideoQuit = DC_VideoQuit;
1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->AllocHWSurface = DC_AllocHWSurface;
1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->CheckHWBlit = NULL;
1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->FillHWRect = NULL;
1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->SetHWColorKey = NULL;
1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->SetHWAlpha = NULL;
1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->LockHWSurface = DC_LockHWSurface;
1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->UnlockHWSurface = DC_UnlockHWSurface;
1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->FlipHWSurface = DC_FlipHWSurface;
1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->FreeHWSurface = DC_FreeHWSurface;
1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->GL_LoadLibrary = DC_GL_LoadLibrary;
1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->GL_GetProcAddress = DC_GL_GetProcAddress;
1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->GL_GetAttribute = DC_GL_GetAttribute;
1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->GL_MakeCurrent = NULL;
1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->GL_SwapBuffers = DC_GL_SwapBuffers;
1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->SetCaption = NULL;
1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->SetIcon = NULL;
1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->IconifyWindow = NULL;
1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->GrabInput = NULL;
1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->GetWMInfo = NULL;
1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->InitOSKeymap = DC_InitOSKeymap;
1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->PumpEvents = DC_PumpEvents;
1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	device->free = DC_DeleteDevice;
1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return device;
1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallVideoBootStrap DC_bootstrap = {
1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	"dcvideo", "Dreamcast Video",
1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DC_Available, DC_CreateDevice
1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall};
1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint DC_VideoInit(_THIS, SDL_PixelFormat *vformat)
1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Determine the screen depth (use default 16-bit depth) */
1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* we change this during the SDL_SetVideoMode implementation... */
1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	vformat->BitsPerPixel = 16;
1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	vformat->Rmask = 0x0000f800;
1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	vformat->Gmask = 0x000007e0;
1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	vformat->Bmask = 0x0000001f;
1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* We're done! */
1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return(0);
1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallconst static SDL_Rect
1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	RECT_800x600 = {0,0,800,600},
1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	RECT_640x480 = {0,0,640,480},
1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	RECT_320x240 = {0,0,320,240};
1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallconst static SDL_Rect *vid_modes[] = {
1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	&RECT_800x600,
1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	&RECT_640x480,
1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	&RECT_320x240,
1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	NULL
1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall};
1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_Rect **DC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	switch(format->BitsPerPixel) {
1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case 15:
1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case 16:
1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		return &vid_modes;
1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case 32:
1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		if (!(flags & SDL_OPENGL))
1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		return &vid_modes;
1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	default:
1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		return NULL;
1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//	return (SDL_Rect **) -1;
1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallpvr_init_params_t params = {
1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        /* Enable opaque and translucent polygons with size 16 */
1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        { PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16 },
1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        /* Vertex buffer size */
1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        512*1024
1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall};
1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int pvr_inited;
1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_Surface *DC_SetVideoMode(_THIS, SDL_Surface *current,
1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall				int width, int height, int bpp, Uint32 flags)
1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int disp_mode,pixel_mode,pitch;
1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	Uint32 Rmask, Gmask, Bmask;
1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if (width==320 && height==240) disp_mode=DM_320x240;
1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	else if (width==640 && height==480) disp_mode=DM_640x480;
1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	else if (width==800 && height==600) disp_mode=DM_800x608;
1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	else {
2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		SDL_SetError("Couldn't find requested mode in list");
2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		return(NULL);
2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	switch(bpp) {
2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case 15: pixel_mode = PM_RGB555; pitch = width*2;
2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		/* 5-5-5 */
2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Rmask = 0x00007c00;
2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Gmask = 0x000003e0;
2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Bmask = 0x0000001f;
2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case 16: pixel_mode = PM_RGB565; pitch = width*2;
2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		/* 5-6-5 */
2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Rmask = 0x0000f800;
2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Gmask = 0x000007e0;
2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Bmask = 0x0000001f;
2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case 24: bpp = 32;
2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case 32: pixel_mode = PM_RGB888; pitch = width*4;
2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Rmask = 0x00ff0000;
2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Gmask = 0x0000ff00;
2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		Bmask = 0x000000ff;
2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		if (!(flags & SDL_OPENGL))
2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	default:
2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		SDL_SetError("Couldn't find requested mode in list");
2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		return(NULL);
2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//  if ( bpp != current->format->BitsPerPixel ) {
2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if ( ! SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0) ) {
2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		return(NULL);
2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//  }
2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Set up the new mode framebuffer */
2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	current->w = width;
2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	current->h = height;
2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	current->pitch = pitch;
2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if (pvr_inited) {
2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		pvr_inited = 0;
2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		pvr_shutdown();
2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	vid_set_mode(disp_mode,pixel_mode);
2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	current->pixels = vram_s;
2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if (flags & SDL_OPENGL) {
2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		this->gl_config.driver_loaded = 1;
2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		current->flags = SDL_FULLSCREEN | SDL_OPENGL;
2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		current->pixels = NULL;
2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		pvr_inited = 1;
2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		pvr_init(&params);
2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		glKosInit();
2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		glKosBeginFrame();
2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	} else
2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if (flags | SDL_DOUBLEBUF) {
2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		current->flags |= SDL_DOUBLEBUF;
2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		current->pixels = (void*)((int)current->pixels | 0x400000);
2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* We're done */
2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return(current);
2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* We don't actually allow hardware surfaces other than the main one */
2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_AllocHWSurface(_THIS, SDL_Surface *surface)
2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return(-1);
2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_FreeHWSurface(_THIS, SDL_Surface *surface)
2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return;
2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* We need to wait for vertical retrace on page flipped displays */
2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_LockHWSurface(_THIS, SDL_Surface *surface)
2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return(0);
2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_UnlockHWSurface(_THIS, SDL_Surface *surface)
2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return;
2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_FlipHWSurface(_THIS, SDL_Surface *surface)
2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if (surface->flags & SDL_DOUBLEBUF) {
2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		vid_set_start((int)surface->pixels & 0xffffff);
2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		surface->pixels = (void*)((int)surface->pixels ^ 0x400000);
3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return(0);
3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* do nothing. */
3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* do nothing of note. */
3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return(1);
3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Note:  If we are terminated, this could be called in the middle of
3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall   another SDL video routine -- notably UpdateRects.
3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_VideoQuit(_THIS)
3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if (pvr_inited) {
3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		pvr_inited = 0;
3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		pvr_shutdown();
3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL
3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid dmyfunc(void) {}
3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef void (*funcptr)();
3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallconst static struct {
3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	char *name;
3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	funcptr addr;
3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} glfuncs[] = {
3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define	DEF(func)	{#func,&func}
3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glBegin),
3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glBindTexture),
3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glBlendFunc),
3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glColor4f),
3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//	DEF(glCopyImageID),
3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glDisable),
3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glEnable),
3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glEnd),
3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glFlush),
3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glGenTextures),
3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glGetString),
3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glLoadIdentity),
3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glMatrixMode),
3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glOrtho),
3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glPixelStorei),
3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//	DEF(glPopAttrib),
3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//	DEF(glPopClientAttrib),
3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	{"glPopAttrib",&dmyfunc},
3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	{"glPopClientAttrib",&dmyfunc},
3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glPopMatrix),
3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//	DEF(glPushAttrib),
3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//	DEF(glPushClientAttrib),
3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	{"glPushAttrib",&dmyfunc},
3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	{"glPushClientAttrib",&dmyfunc},
3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glPushMatrix),
3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glTexCoord2f),
3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glTexEnvf),
3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glTexImage2D),
3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glTexParameteri),
3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glTexSubImage2D),
3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glVertex2i),
3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	DEF(glViewport),
3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#undef	DEF
3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall};
3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void *DC_GL_GetProcAddress(_THIS, const char *proc)
3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	void *ret;
3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int i;
3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	ret = glKosGetProcAddress(proc);
3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	if (ret) return ret;
3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	for(i=0;i<sizeof(glfuncs)/sizeof(glfuncs[0]);i++) {
3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		if (SDL_strcmp(proc,glfuncs[i].name)==0) return glfuncs[i].addr;
3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return NULL;
3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_GL_LoadLibrary(_THIS, const char *path)
3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	this->gl_config.driver_loaded = 1;
3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return 0;
3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int DC_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	GLenum mesa_attrib;
3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int val;
3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	switch(attrib) {
4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_RED_SIZE:
4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 5;
4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_GREEN_SIZE:
4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 6;
4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_BLUE_SIZE:
4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 5;
4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_ALPHA_SIZE:
4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 0;
4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_DOUBLEBUFFER:
4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 1;
4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_DEPTH_SIZE:
4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 16; /* or 32? */
4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_STENCIL_SIZE:
4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 0;
4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_ACCUM_RED_SIZE:
4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 0;
4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_ACCUM_GREEN_SIZE:
4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 0;
4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_ACCUM_BLUE_SIZE:
4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 0;
4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	case SDL_GL_ACCUM_ALPHA_SIZE:
4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		val = 0;
4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		break;
4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	default :
4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		return -1;
4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	*value = val;
4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	return 0;
4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void DC_GL_SwapBuffers(_THIS)
4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	glKosFinishFrame();
4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	glKosBeginFrame();
4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
446