Home | History | Annotate | Download | only in gapi
      1 /*
      2     SDL - Simple DirectMedia Layer
      3     Copyright (C) 1997-2006 Sam Lantinga
      4 
      5     This library is free software; you can redistribute it and/or
      6     modify it under the terms of the GNU Lesser General Public
      7     License as published by the Free Software Foundation; either
      8     version 2.1 of the License, or (at your option) any later version.
      9 
     10     This library is distributed in the hope that it will be useful,
     11     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13     Lesser General Public License for more details.
     14 
     15     You should have received a copy of the GNU Lesser General Public
     16     License along with this library; if not, write to the Free Software
     17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     18 
     19     Sam Lantinga
     20     slouken (at) libsdl.org
     21 */
     22 #include "SDL_config.h"
     23 
     24 #ifndef _SDL_gapivideo_h
     25 #define _SDL_gapivideo_h
     26 
     27 #include "SDL_mouse.h"
     28 #include "SDL_mutex.h"
     29 #include "../SDL_sysvideo.h"
     30 
     31 /* From gx.h, since it's not really C compliant */
     32 
     33 struct GXDisplayProperties {
     34     DWORD cxWidth;
     35     DWORD cyHeight;         // notice lack of 'th' in the word height.
     36     long cbxPitch;          // number of bytes to move right one x pixel - can be negative.
     37     long cbyPitch;          // number of bytes to move down one y pixel - can be negative.
     38     long cBPP;              // # of bits in each pixel
     39     DWORD ffFormat;         // format flags.
     40 };
     41 
     42 struct GXKeyList {
     43     short vkUp;             // key for up
     44     POINT ptUp;             // x,y position of key/button.  Not on screen but in screen coordinates.
     45     short vkDown;
     46     POINT ptDown;
     47     short vkLeft;
     48     POINT ptLeft;
     49     short vkRight;
     50     POINT ptRight;
     51     short vkA;
     52     POINT ptA;
     53     short vkB;
     54     POINT ptB;
     55     short vkC;
     56     POINT ptC;
     57     short vkStart;
     58     POINT ptStart;
     59 };
     60 
     61 typedef int   (*PFNGXOpenDisplay)(HWND hWnd, DWORD dwFlags);
     62 typedef int   (*PFNGXCloseDisplay)();
     63 typedef void* (*PFNGXBeginDraw)();
     64 typedef int   (*PFNGXEndDraw)();
     65 typedef int   (*PFNGXOpenInput)();
     66 typedef int   (*PFNGXCloseInput)();
     67 typedef struct GXDisplayProperties (*PFNGXGetDisplayProperties)();
     68 typedef struct GXKeyList (*PFNGXGetDefaultKeys)(int iOptions);
     69 typedef int   (*PFNGXSuspend)();
     70 typedef int   (*PFNGXResume)();
     71 typedef int   (*PFNGXSetViewport)( DWORD dwTop, DWORD dwHeight, DWORD dwReserved1, DWORD dwReserved2 );
     72 typedef BOOL  (*PFNGXIsDisplayDRAMBuffer)();
     73 
     74 struct GapiFunc
     75 {
     76     PFNGXOpenDisplay          GXOpenDisplay;
     77     PFNGXCloseDisplay         GXCloseDisplay;
     78     PFNGXBeginDraw            GXBeginDraw;
     79     PFNGXEndDraw              GXEndDraw;
     80     PFNGXOpenInput            GXOpenInput;
     81     PFNGXCloseInput           GXCloseInput;
     82     PFNGXGetDisplayProperties GXGetDisplayProperties;
     83     PFNGXGetDefaultKeys       GXGetDefaultKeys;
     84     PFNGXSuspend              GXSuspend;
     85     PFNGXResume               GXResume;
     86     PFNGXSetViewport          GXSetViewport;
     87     PFNGXIsDisplayDRAMBuffer  GXIsDisplayDRAMBuffer;
     88 };
     89 
     90 #define kfLandscape	0x8			// Screen is rotated 270 degrees
     91 #define kfPalette	0x10		// Pixel values are indexes into a palette
     92 #define kfDirect	0x20		// Pixel values contain actual level information
     93 #define kfDirect555	0x40		// 5 bits each for red, green and blue values in a pixel.
     94 #define kfDirect565	0x80		// 5 red bits, 6 green bits and 5 blue bits per pixel
     95 #define kfDirect888	0x100		// 8 bits each for red, green and blue values in a pixel.
     96 #define kfDirect444	0x200		// 4 red, 4 green, 4 blue
     97 #define kfDirectInverted 0x400
     98 
     99 #define GX_FULLSCREEN	0x01		// for OpenDisplay()
    100 #define GX_NORMALKEYS   0x02
    101 #define GX_LANDSCAPEKEYS        0x03
    102 
    103 typedef enum
    104 {
    105 	SDL_ORIENTATION_UP,
    106 	SDL_ORIENTATION_DOWN,
    107 	SDL_ORIENTATION_LEFT,
    108 	SDL_ORIENTATION_RIGHT
    109 } SDL_ScreenOrientation;
    110 
    111 /* GAPI video mode */
    112 typedef enum {
    113 	GAPI_NONE = 0,
    114 	GAPI_DIRECT_565,
    115 	GAPI_DIRECT_555,
    116 	GAPI_MONO,
    117 	GAPI_PALETTE
    118 } GAPIVideoMode;
    119 
    120 /* Hidden "this" pointer for the video functions */
    121 #define _THIS	SDL_VideoDevice *this
    122 
    123 typedef unsigned short PIXEL;
    124 
    125 /* Private display data
    126    begin with DIB private structure to allow DIB events code sharing
    127 */
    128 struct SDL_PrivateVideoData {
    129     HBITMAP screen_bmp;
    130     HPALETTE screen_pal;
    131 
    132 #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
    133     int SDL_nummodes[NUM_MODELISTS];
    134     SDL_Rect **SDL_modelist[NUM_MODELISTS];
    135 	enum SDL_ScreenOrientation userOrientation;
    136 	int invert;
    137 	char hiresFix; // using hires mode without defining hires resource
    138 // --------------
    139 	int useGXOpenDisplay; /* use GXOpenDispplay */
    140     int w, h;
    141 	enum SDL_ScreenOrientation gapiOrientation;
    142 
    143     void *buffer; // may be 8, 16, 24, 32 bpp
    144 	PIXEL *videoMem;
    145 	BOOL needUpdate;
    146 	struct GXKeyList keyList;
    147 	struct GapiFunc gxFunc;
    148 	struct GXDisplayProperties gxProperties;
    149 	enum GAPIVideoMode videoMode;
    150 	int colorscale;
    151 	int dstLineStep;  // in bytes
    152 	int dstPixelStep; // in bytes
    153 	int startOffset; // in bytes
    154 	int useVga;
    155 	int suspended; // do not pu anything into video memory
    156 };
    157 
    158 
    159 #define gapiBuffer this->hidden->buffer
    160 #define gapi this->hidden
    161 
    162 #endif /* _SDL_gapivideo_h */
    163