Skip to content

Commit

Permalink
Fixed bug #831
Browse files Browse the repository at this point in the history
 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.
  • Loading branch information
slouken committed Oct 10, 2009
1 parent 7c7d107 commit 1de2e6a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
23 changes: 9 additions & 14 deletions src/video/gapi/SDL_gapivideo.c
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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? */
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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) )
{
Expand All @@ -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;

Expand All @@ -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);


Expand Down
1 change: 1 addition & 0 deletions src/video/gapi/SDL_gapivideo.h
Expand Up @@ -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;
Expand Down
46 changes: 23 additions & 23 deletions src/video/windib/SDL_dibevents.c
Expand Up @@ -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;
}
Sint16 temp = *x;
*x = SDL_VideoSurface->w - *y;
*y = temp;
}
else
if(gapiInfo->userOrientation == SDL_ORIENTATION_RIGHT &&
gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT)
// 0 0 0
if((!gapiInfo->userOrientation && !gapiInfo->systemOrientation && !gapiInfo->gapiOrientation) ||
// 0 0 3
(!gapiInfo->userOrientation && !gapiInfo->systemOrientation && gapiInfo->gapiOrientation))
{
rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
SDL_VideoSurface->format->BytesPerPixel))
+ SDL_VideoSurface->w - *y;
rotatedY = *x;
*x = rotatedX;
*y = rotatedY;
// without changes
// *x = *x;
// *y = *y;
}
// default
else
{
rotatedX = SDL_VideoSurface->w - *y;
rotatedY = *x;
*y = rotatedY;
*x = rotatedX;
// without changes
// *x = *x;
// *y = *y;
}
}
#endif
Expand Down

0 comments on commit 1de2e6a

Please sign in to comment.