X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=video.c;h=a33accfe70a7fece61be7273ba984d1128580651;hb=eb3668fc5dab138073cd4844208ac05b94086a4a;hp=b857bf15c053dd0a06735f10d8a1e6a0dab27d1f;hpb=42c8119010bfc48776e8c82e42cceb06d07c0247;p=gpsp.git diff --git a/video.c b/video.c index b857bf1..a33accf 100644 --- a/video.c +++ b/video.c @@ -102,6 +102,16 @@ const u32 screen_pitch = 320; #define get_screen_pitch() \ screen_pitch \ +#elif defined(PND_BUILD) + +static u16 *screen_pixels = NULL; + +#define get_screen_pixels() \ + screen_pixels \ + +#define get_screen_pitch() \ + resolution_width \ + #else #ifdef GP2X_BUILD @@ -2403,7 +2413,7 @@ fill_line_builder(color32); #ifdef RENDER_COLOR16_NORMAL -#ifndef GP2X_BUILD +#ifndef ARM_ARCH void expand_normal(u16 *screen_ptr, u32 start, u32 end) { @@ -2432,7 +2442,10 @@ void expand_normal(u16 *screen_ptr, u32 start, u32 end) #endif -#ifndef GP2X_BUILD +void expand_blend(u32 *screen_src_ptr, u16 *screen_dest_ptr, + u32 start, u32 end); + +#ifndef ARM_ARCH void expand_blend(u32 *screen_src_ptr, u16 *screen_dest_ptr, u32 start, u32 end) @@ -3389,6 +3402,13 @@ no_clean: screen_pixels = (u16 *)gpsp_gp2x_screen + screen_offset; } +#elif defined(PND_BUILD) + +void flip_screen() +{ + screen_pixels = fb_flip_screen(); +} + #else #define integer_scale_copy_2() \ @@ -3464,26 +3484,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); @@ -3587,7 +3618,7 @@ void init_video() GE_CMD(NOP, 0); } -#elif defined(WIZ_BUILD) +#elif defined(WIZ_BUILD) || defined(PND_BUILD) void init_video() { @@ -3782,6 +3813,42 @@ void clear_screen(u16 color) *p++ = col; } +#elif defined(PND_BUILD) + +void video_resolution_large() +{ + resolution_width = 400; + resolution_height = 272; + + fb_set_mode(400, 272, 1, 15, screen_filter); + flip_screen(); + clear_screen(0); +} + +void video_resolution_small() +{ + resolution_width = 240; + resolution_height = 160; + + fb_set_mode(240, 160, 4, screen_scale, screen_filter); + flip_screen(); + clear_screen(0); +} + +void set_gba_resolution(video_scale_type scale) +{ + screen_scale = scale; +} + +void clear_screen(u16 color) +{ + u32 col = ((u32)color << 16) | color; + u32 *p = (u32 *)get_screen_pixels(); + int c = resolution_width * resolution_height / 2; + while (c-- > 0) + *p++ = col; +} + #else void video_resolution_large() @@ -3816,7 +3883,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 +3891,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); @@ -3886,17 +3956,18 @@ void blit_to_screen(u16 *src, u32 w, u32 h, u32 dest_x, u32 dest_y) u32 pitch = get_screen_pitch(); u16 *dest_ptr = get_screen_pixels() + dest_x + (dest_y * pitch); + s32 w1 = dest_x + w > pitch ? pitch - dest_x : w; u16 *src_ptr = src; - u32 line_skip = pitch - w; - u32 x, y; + s32 x, y; for(y = 0; y < h; y++) { - for(x = 0; x < w; x++, src_ptr++, dest_ptr++) + for(x = 0; x < w1; x++) { - *dest_ptr = *src_ptr; + dest_ptr[x] = src_ptr[x]; } - dest_ptr += line_skip; + src_ptr += w; + dest_ptr += pitch; } }