mirror of
https://github.com/yawut/SDL.git
synced 2026-10-02 05:06:46 -05:00
Fixed bug #831
Andrey 2009-10-09 08:08:04 PDT gapi_hires_fix I made a mistake with the conclusions. And last time I as was mistaken with conclusions. Now I thought about in more detail the algorithm works. I have made it that the project fheroes2 well worked. The result of my work in attachment. I have a possibility to check up it on different models pocketpc. I checked various modes screen of 320x320, 320x240, 640x480, 800x400. --HG-- branch : SDL-1.2
This commit is contained in:
@@ -622,7 +622,6 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
Uint32 Rmask, Gmask, Bmask;
|
||||
DWORD style;
|
||||
SDL_Rect allScreen;
|
||||
SDL_ScreenOrientation systemOrientation;
|
||||
|
||||
if( bpp < 4 )
|
||||
{
|
||||
@@ -674,7 +673,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
}
|
||||
|
||||
gapi->userOrientation = SDL_ORIENTATION_UP;
|
||||
systemOrientation = SDL_ORIENTATION_UP;
|
||||
gapi->systemOrientation = SDL_ORIENTATION_UP;
|
||||
video->flags = SDL_FULLSCREEN; /* Clear flags, GAPI supports fullscreen only */
|
||||
|
||||
/* GAPI or VGA? */
|
||||
@@ -697,18 +696,15 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
gapi->userOrientation = SDL_ORIENTATION_RIGHT;
|
||||
|
||||
if(GetSystemMetrics(SM_CYSCREEN) < GetSystemMetrics(SM_CXSCREEN))
|
||||
systemOrientation = SDL_ORIENTATION_RIGHT;
|
||||
gapi->systemOrientation = SDL_ORIENTATION_RIGHT;
|
||||
|
||||
/* shall we apply hires fix? for example when we do not use hires resource */
|
||||
gapi->hiresFix = 0;
|
||||
if( systemOrientation == gapi->userOrientation )
|
||||
|
||||
/* check hires */
|
||||
if(GetSystemMetrics(SM_CXSCREEN) < width && GetSystemMetrics(SM_CYSCREEN) < height)
|
||||
{
|
||||
if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height > GetSystemMetrics(SM_CYSCREEN)))
|
||||
gapi->hiresFix = 1;
|
||||
} else
|
||||
if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height > GetSystemMetrics(SM_CXSCREEN)))
|
||||
// if( !((width == gapi->gxProperties.cyHeight) && (height == gapi->gxProperties.cxWidth))) // user portrait, device landscape
|
||||
gapi->hiresFix = 1;
|
||||
gapi->hiresFix = 1;
|
||||
}
|
||||
|
||||
switch( gapi->userOrientation )
|
||||
{
|
||||
@@ -783,7 +779,6 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
printf("system display width (orig): %d\n", GetSystemMetrics(SM_CXSCREEN));
|
||||
printf("system display height (orig): %d\n", GetSystemMetrics(SM_CYSCREEN));
|
||||
#endif
|
||||
gapi->hiresFix = (width > GetSystemMetrics(SM_CXSCREEN)) || (height > GetSystemMetrics(SM_CYSCREEN));
|
||||
gapi->alreadyGXOpened = 1;
|
||||
if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) )
|
||||
{
|
||||
@@ -793,7 +788,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
}
|
||||
|
||||
if(gapi->useVga)
|
||||
gapi->coordinateTransform = (4 - systemOrientation + gapi->userOrientation) % 4;
|
||||
gapi->coordinateTransform = (4 - gapi->systemOrientation + gapi->userOrientation) % 4;
|
||||
else
|
||||
gapi->coordinateTransform = gapi->userOrientation;
|
||||
|
||||
@@ -808,7 +803,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
printf("y pitch: %d\n", gapi->gxProperties.cbyPitch);
|
||||
printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat);
|
||||
printf("user orientation: %d\n", gapi->userOrientation);
|
||||
printf("system orientation: %d\n", systemOrientation);
|
||||
printf("system orientation: %d\n", gapi->systemOrientation);
|
||||
printf("gapi orientation: %d\n", gapi->gapiOrientation);
|
||||
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ struct GapiInfo {
|
||||
// The orientation of the video mode user wants to get
|
||||
// Probably restricted to UP and RIGHT
|
||||
SDL_ScreenOrientation userOrientation;
|
||||
SDL_ScreenOrientation systemOrientation;
|
||||
// --------------
|
||||
int useGXOpenDisplay; /* use GXOpenDispplay */
|
||||
int alreadyGXOpened;
|
||||
|
||||
@@ -88,41 +88,41 @@ WPARAM rotateKey(WPARAM key,int direction)
|
||||
return key;
|
||||
}
|
||||
|
||||
static void GapiTransform(GapiInfo *gapiInfo, LONG *x, LONG *y) {
|
||||
Sint16 rotatedX;
|
||||
Sint16 rotatedY;
|
||||
|
||||
static void GapiTransform(GapiInfo *gapiInfo, LONG *x, LONG *y)
|
||||
{
|
||||
if(gapiInfo->hiresFix)
|
||||
{
|
||||
*x *= 2;
|
||||
*y *= 2;
|
||||
}
|
||||
|
||||
if(gapiInfo->userOrientation == SDL_ORIENTATION_UP &&
|
||||
gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT)
|
||||
// 0 3 0
|
||||
if((!gapiInfo->userOrientation && gapiInfo->systemOrientation && !gapiInfo->gapiOrientation) ||
|
||||
// 3 0 3
|
||||
(gapiInfo->userOrientation && !gapiInfo->systemOrientation && gapiInfo->gapiOrientation) ||
|
||||
// 3 0 0
|
||||
(gapiInfo->userOrientation && !gapiInfo->systemOrientation && !gapiInfo->gapiOrientation))
|
||||
{
|
||||
rotatedX = *x;
|
||||
rotatedY = *y;
|
||||
*x = rotatedX;
|
||||
*y = rotatedY;
|
||||
}
|
||||
else
|
||||
if(gapiInfo->userOrientation == SDL_ORIENTATION_RIGHT &&
|
||||
gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT)
|
||||
{
|
||||
rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
|
||||
SDL_VideoSurface->format->BytesPerPixel))
|
||||
+ SDL_VideoSurface->w - *y;
|
||||
rotatedY = *x;
|
||||
*x = rotatedX;
|
||||
*y = rotatedY;
|
||||
Sint16 temp = *x;
|
||||
*x = SDL_VideoSurface->w - *y;
|
||||
*y = temp;
|
||||
}
|
||||
else
|
||||
// 0 0 0
|
||||
if((!gapiInfo->userOrientation && !gapiInfo->systemOrientation && !gapiInfo->gapiOrientation) ||
|
||||
// 0 0 3
|
||||
(!gapiInfo->userOrientation && !gapiInfo->systemOrientation && gapiInfo->gapiOrientation))
|
||||
{
|
||||
rotatedX = SDL_VideoSurface->w - *y;
|
||||
rotatedY = *x;
|
||||
*y = rotatedY;
|
||||
*x = rotatedX;
|
||||
// without changes
|
||||
// *x = *x;
|
||||
// *y = *y;
|
||||
}
|
||||
// default
|
||||
else
|
||||
{
|
||||
// without changes
|
||||
// *x = *x;
|
||||
// *y = *y;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user