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#ifndef _SDL_gapivideo_h
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define _SDL_gapivideo_h
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_mouse.h"
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_mutex.h"
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_sysvideo.h"
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../windib/SDL_gapidibvideo.h"
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* From gx.h, since it's not really C compliant */
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstruct GXDisplayProperties {
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    DWORD cxWidth;
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    DWORD cyHeight;         // notice lack of 'th' in the word height.
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    long cbxPitch;          // number of bytes to move right one x pixel - can be negative.
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    long cbyPitch;          // number of bytes to move down one y pixel - can be negative.
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    long cBPP;              // # of bits in each pixel
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    DWORD ffFormat;         // format flags.
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall};
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstruct GXKeyList {
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    short vkUp;             // key for up
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    POINT ptUp;             // x,y position of key/button.  Not on screen but in screen coordinates.
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    short vkDown;
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    POINT ptDown;
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    short vkLeft;
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    POINT ptLeft;
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    short vkRight;
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    POINT ptRight;
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    short vkA;
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    POINT ptA;
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    short vkB;
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    POINT ptB;
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    short vkC;
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    POINT ptC;
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    short vkStart;
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    POINT ptStart;
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall};
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int   (*PFNGXOpenDisplay)(HWND hWnd, DWORD dwFlags);
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int   (*PFNGXCloseDisplay)();
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef void* (*PFNGXBeginDraw)();
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int   (*PFNGXEndDraw)();
669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int   (*PFNGXOpenInput)();
679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int   (*PFNGXCloseInput)();
689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct GXDisplayProperties (*PFNGXGetDisplayProperties)();
699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef struct GXKeyList (*PFNGXGetDefaultKeys)(int iOptions);
709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int   (*PFNGXSuspend)();
719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int   (*PFNGXResume)();
729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef int   (*PFNGXSetViewport)( DWORD dwTop, DWORD dwHeight, DWORD dwReserved1, DWORD dwReserved2 );
739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef BOOL  (*PFNGXIsDisplayDRAMBuffer)();
749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstruct GapiFunc
769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXOpenDisplay          GXOpenDisplay;
789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXCloseDisplay         GXCloseDisplay;
799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXBeginDraw            GXBeginDraw;
809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXEndDraw              GXEndDraw;
819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXOpenInput            GXOpenInput;
829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXCloseInput           GXCloseInput;
839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXGetDisplayProperties GXGetDisplayProperties;
849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXGetDefaultKeys       GXGetDefaultKeys;
859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXSuspend              GXSuspend;
869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXResume               GXResume;
879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXSetViewport          GXSetViewport;
889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    PFNGXIsDisplayDRAMBuffer  GXIsDisplayDRAMBuffer;
899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall};
909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kfLandscape	0x8			// Screen is rotated 270 degrees
929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kfPalette	0x10		// Pixel values are indexes into a palette
939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kfDirect	0x20		// Pixel values contain actual level information
949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kfDirect555	0x40		// 5 bits each for red, green and blue values in a pixel.
959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kfDirect565	0x80		// 5 red bits, 6 green bits and 5 blue bits per pixel
969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kfDirect888	0x100		// 8 bits each for red, green and blue values in a pixel.
979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kfDirect444	0x200		// 4 red, 4 green, 4 blue
989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kfDirectInverted 0x400
999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define GX_FULLSCREEN	0x01		// for OpenDisplay()
1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define GX_NORMALKEYS   0x02
1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define GX_LANDSCAPEKEYS        0x03
1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* GAPI video mode */
1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef enum {
1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	GAPI_NONE = 0,
1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	GAPI_DIRECT_565,
1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	GAPI_DIRECT_555,
1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	GAPI_MONO,
1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	GAPI_PALETTE
1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} GAPIVideoMode;
1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Halltypedef unsigned short PIXEL;
1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Private display data
1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall   begin with DIB private structure to allow DIB events code sharing
1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstruct GapiInfo {
1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	/* Rotation which has to be applied to the key (arrow keys) and mouse events measured in quarters of a circle
1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	 * counter clockwise */
1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int coordinateTransform;
1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	char hiresFix; /* using hires mode without defining hires resource */
1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int invert; //TODO this is only written but never read, so it should be removed
1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int SDL_nummodes[NUM_MODELISTS];
1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_Rect **SDL_modelist[NUM_MODELISTS];
1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	// The orientation of the video mode user wants to get
1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	// Probably restricted to UP and RIGHT
1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_ScreenOrientation userOrientation;
1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_ScreenOrientation systemOrientation;
1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// --------------
1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int useGXOpenDisplay; /* use GXOpenDispplay */
1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int alreadyGXOpened;
1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int w, h;
1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	// The orientation of GAPI framebuffer.
1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	// Never changes on the same device.
1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_ScreenOrientation gapiOrientation;
1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	void *buffer; // may be 8, 16, 24, 32 bpp
1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	PIXEL *videoMem;
1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	BOOL needUpdate;
1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	struct GXKeyList keyList;
1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	struct GapiFunc gxFunc;
1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	struct GXDisplayProperties gxProperties;
1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	GAPIVideoMode videoMode;
1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int colorscale;
1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int dstLineStep;  // in bytes
1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int dstPixelStep; // in bytes
1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int startOffset; // in bytes
1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int useVga;
1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int suspended; // do not pu anything into video memory
1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall};
1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* _SDL_gapivideo_h */
161