Commit dbb19d20 authored by Sam Lantinga's avatar Sam Lantinga

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
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%403996
parent f8cb9e88
...@@ -622,7 +622,6 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -622,7 +622,6 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
Uint32 Rmask, Gmask, Bmask; Uint32 Rmask, Gmask, Bmask;
DWORD style; DWORD style;
SDL_Rect allScreen; SDL_Rect allScreen;
SDL_ScreenOrientation systemOrientation;
if( bpp < 4 ) if( bpp < 4 )
{ {
...@@ -674,7 +673,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -674,7 +673,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
} }
gapi->userOrientation = SDL_ORIENTATION_UP; gapi->userOrientation = SDL_ORIENTATION_UP;
systemOrientation = SDL_ORIENTATION_UP; gapi->systemOrientation = SDL_ORIENTATION_UP;
video->flags = SDL_FULLSCREEN; /* Clear flags, GAPI supports fullscreen only */ video->flags = SDL_FULLSCREEN; /* Clear flags, GAPI supports fullscreen only */
/* GAPI or VGA? */ /* GAPI or VGA? */
...@@ -697,18 +696,15 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -697,18 +696,15 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
gapi->userOrientation = SDL_ORIENTATION_RIGHT; gapi->userOrientation = SDL_ORIENTATION_RIGHT;
if(GetSystemMetrics(SM_CYSCREEN) < GetSystemMetrics(SM_CXSCREEN)) 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; 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 ) switch( gapi->userOrientation )
{ {
...@@ -783,7 +779,6 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -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 width (orig): %d\n", GetSystemMetrics(SM_CXSCREEN));
printf("system display height (orig): %d\n", GetSystemMetrics(SM_CYSCREEN)); printf("system display height (orig): %d\n", GetSystemMetrics(SM_CYSCREEN));
#endif #endif
gapi->hiresFix = (width > GetSystemMetrics(SM_CXSCREEN)) || (height > GetSystemMetrics(SM_CYSCREEN));
gapi->alreadyGXOpened = 1; gapi->alreadyGXOpened = 1;
if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) ) if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) )
{ {
...@@ -793,7 +788,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -793,7 +788,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
} }
if(gapi->useVga) if(gapi->useVga)
gapi->coordinateTransform = (4 - systemOrientation + gapi->userOrientation) % 4; gapi->coordinateTransform = (4 - gapi->systemOrientation + gapi->userOrientation) % 4;
else else
gapi->coordinateTransform = gapi->userOrientation; gapi->coordinateTransform = gapi->userOrientation;
...@@ -808,7 +803,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -808,7 +803,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
printf("y pitch: %d\n", gapi->gxProperties.cbyPitch); printf("y pitch: %d\n", gapi->gxProperties.cbyPitch);
printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat); printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat);
printf("user orientation: %d\n", gapi->userOrientation); 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); printf("gapi orientation: %d\n", gapi->gapiOrientation);
......
...@@ -131,6 +131,7 @@ struct GapiInfo { ...@@ -131,6 +131,7 @@ struct GapiInfo {
// The orientation of the video mode user wants to get // The orientation of the video mode user wants to get
// Probably restricted to UP and RIGHT // Probably restricted to UP and RIGHT
SDL_ScreenOrientation userOrientation; SDL_ScreenOrientation userOrientation;
SDL_ScreenOrientation systemOrientation;
// -------------- // --------------
int useGXOpenDisplay; /* use GXOpenDispplay */ int useGXOpenDisplay; /* use GXOpenDispplay */
int alreadyGXOpened; int alreadyGXOpened;
......
...@@ -88,41 +88,41 @@ WPARAM rotateKey(WPARAM key,int direction) ...@@ -88,41 +88,41 @@ WPARAM rotateKey(WPARAM key,int direction)
return key; return key;
} }
static void GapiTransform(GapiInfo *gapiInfo, LONG *x, LONG *y) { static void GapiTransform(GapiInfo *gapiInfo, LONG *x, LONG *y)
Sint16 rotatedX; {
Sint16 rotatedY;
if(gapiInfo->hiresFix) if(gapiInfo->hiresFix)
{ {
*x *= 2; *x *= 2;
*y *= 2; *y *= 2;
} }
if(gapiInfo->userOrientation == SDL_ORIENTATION_UP && // 0 3 0
gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT) 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; Sint16 temp = *x;
rotatedY = *y; *x = SDL_VideoSurface->w - *y;
*x = rotatedX; *y = temp;
*y = rotatedY;
} }
else else
if(gapiInfo->userOrientation == SDL_ORIENTATION_RIGHT && // 0 0 0
gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT) if((!gapiInfo->userOrientation && !gapiInfo->systemOrientation && !gapiInfo->gapiOrientation) ||
// 0 0 3
(!gapiInfo->userOrientation && !gapiInfo->systemOrientation && gapiInfo->gapiOrientation))
{ {
rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ // without changes
SDL_VideoSurface->format->BytesPerPixel)) // *x = *x;
+ SDL_VideoSurface->w - *y; // *y = *y;
rotatedY = *x;
*x = rotatedX;
*y = rotatedY;
} }
// default
else else
{ {
rotatedX = SDL_VideoSurface->w - *y; // without changes
rotatedY = *x; // *x = *x;
*y = rotatedY; // *y = *y;
*x = rotatedX;
} }
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment