From 4cadce9738bb306c1c31cde89f91feb8132875cf Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 23 Jun 2009 00:24:56 +0300 Subject: [PATCH] sw scaler for gp2x --- gui.c | 2 +- video.c | 52 +++++++++++++++++++++++++++++++++------------------- video.h | 10 +++++++--- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/gui.c b/gui.c index b1a2d7d..a2ae99e 100644 --- a/gui.c +++ b/gui.c @@ -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 diff --git a/video.c b/video.c index b857bf1..8730650 100644 --- a/video.c +++ b/video.c @@ -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); diff --git a/video.h b/video.h index cb717f2..40c24c2 100644 --- a/video.h +++ b/video.h @@ -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 -- 2.39.5