sw scaler for gp2x

This commit is contained in:
notaz 2009-06-23 00:24:56 +03:00
parent 1d02ca7575
commit 4cadce9738
3 changed files with 41 additions and 23 deletions

2
gui.c
View File

@ -756,7 +756,7 @@ u8 *scale_options[] =
"unscaled 3:2", "scaled 3:2 (slower)",
"unscaled 3:2 (anti-tear)", "scaled 3:2 (anti-tear)"
#else
"unscaled 3:2", "scaled 3:2", "fullscreen"
"unscaled 3:2", "scaled 3:2", "fullscreen", "scaled 3:2 (software)"
#ifdef PSP_BUILD
" 16:9"
#endif

52
video.c
View File

@ -3464,26 +3464,37 @@ void flip_screen()
}
#ifdef GP2X_BUILD
{
if((screen_scale == unscaled) &&
(resolution_width == small_resolution_width) &&
if((resolution_width == small_resolution_width) &&
(resolution_height == small_resolution_height))
{
SDL_Rect srect = {0, 0, 240, 160};
SDL_Rect drect = {40, 40, 240, 160};
SDL_BlitSurface(screen, &srect, hw_screen, &drect);
}
else if((screen_scale == scaled_aspect) &&
(resolution_width == small_resolution_width) &&
(resolution_height == small_resolution_height))
{
SDL_Rect drect = {0, 10, 0, 0};
SDL_BlitSurface(screen, NULL, hw_screen, &drect);
}
else
{
SDL_BlitSurface(screen, NULL, hw_screen, NULL);
switch (screen_scale)
{
case unscaled:
{
SDL_Rect srect = {0, 0, 240, 160};
SDL_Rect drect = {40, 40, 240, 160};
warm_cache_op_all(WOP_D_CLEAN);
SDL_BlitSurface(screen, &srect, hw_screen, &drect);
return;
}
case scaled_aspect:
{
SDL_Rect drect = {0, 10, 0, 0};
warm_cache_op_all(WOP_D_CLEAN);
SDL_BlitSurface(screen, NULL, hw_screen, &drect);
return;
}
case scaled_aspect_sw:
{
upscale_aspect(hw_screen->pixels, get_screen_pixels());
return;
}
case fullscreen:
break;
}
}
warm_cache_op_all(WOP_D_CLEAN);
SDL_BlitSurface(screen, NULL, hw_screen, NULL);
}
#else
SDL_Flip(screen);
@ -3816,7 +3827,7 @@ void video_resolution_small()
SDL_GP2X_AllowGfxMemory(NULL, 0);
w = 320; h = 240;
if (screen_scale != unscaled)
if (screen_scale == scaled_aspect || screen_scale == fullscreen)
{
w = small_resolution_width * video_scale;
h = small_resolution_height * video_scale;
@ -3824,9 +3835,12 @@ void video_resolution_small()
if (screen_scale == scaled_aspect) h += 20;
hw_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE);
w = small_resolution_width * video_scale;
if (screen_scale == scaled_aspect_sw)
w = 320;
screen = SDL_CreateRGBSurface(SDL_HWSURFACE,
small_resolution_width * video_scale, small_resolution_height *
video_scale, 16, 0xFFFF, 0xFFFF, 0xFFFF, 0);
w, small_resolution_height * video_scale,
16, 0xFFFF, 0xFFFF, 0xFFFF, 0);
SDL_ShowCursor(0);

10
video.h
View File

@ -77,11 +77,15 @@ typedef enum
{
unscaled,
scaled_aspect,
#ifndef WIZ_BUILD
fullscreen,
#endif
#ifdef WIZ_BUILD
unscaled_rot,
scaled_aspect_rot,
#elif defined(GP2X_BUILD)
fullscreen,
scaled_aspect_sw,
#else
fullscreen,
#endif
} video_scale_type;
typedef enum