From 5883cd9072e607d468178b8188b19416b66986e3 Mon Sep 17 00:00:00 2001 From: Nils Kneuper Date: Tue, 13 Dec 2011 14:03:42 +0100 Subject: [PATCH] slight cleanup of the rendering code and some (minimal) speed improvement for hardware scaled as well as "high res" mode in 2x2 no-AA --- unix/pandora_scaling/simple_noAA_scaler.cpp | 40 ++++++++++----------- unix/unix.cpp | 3 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/unix/pandora_scaling/simple_noAA_scaler.cpp b/unix/pandora_scaling/simple_noAA_scaler.cpp index 555af30..1479b1d 100644 --- a/unix/pandora_scaling/simple_noAA_scaler.cpp +++ b/unix/pandora_scaling/simple_noAA_scaler.cpp @@ -3,22 +3,21 @@ void render_x_single_xy(uint16* destination_pointer_address, uint16 screen_pitch_half, uint16* gfx_screen, uint16 source_panewidth, int Width, int Height) { - uint16 height_desired = Height/* << 1*/; // height_desired = Height * 2 + uint16 height_desired = Height; uint16 bytes_per_line = Width << 1; // bytes_per_line = Width * 2 + + // sp is the pointer to a pixel in the SDL screen + register uint16 *sp16 = gfx_screen; + // dp is the pointer to a pixel in the "real" screen + register uint16 *dp16 = destination_pointer_address; + for (register uint16 i = 0; i < height_desired; ++i) { - // dp is the pointer to a pixel in the "real" screen - register uint16 *dp16 = destination_pointer_address + ( i * screen_pitch_half ); - - // sp is the pointer to a pixel in the SDL screen - register uint16 *sp16 = gfx_screen; - // ( i / 2 ) * source_panewidth; "i/2" for doubling lines, aka "deinterlacing" - sp16 += ( ( i /*>> 1*/ ) * source_panewidth ); - //since we apply no scaling in X dimension here, we can simply use a single memcpy instead of a for loop memcpy ( dp16, sp16, bytes_per_line ); - //for (register uint16 j = 0; j < Width ; ++j, ++sp16) { - // *dp16++ = *sp16; - //} + + // update the references to display and sdl screen for the next run + dp16 += screen_pitch_half; + sp16 += source_panewidth; } // for each height unit } @@ -26,20 +25,19 @@ void render_x_single(uint16* destination_pointer_address, uint16 screen_pitch_ha uint16* gfx_screen, uint16 source_panewidth, int Width, int Height) { uint16 height_desired = Height << 1; // height_desired = Height * 2 uint16 bytes_per_line = Width << 1; // bytes_per_line = Width * 2 + + // dp is the pointer to a pixel in the "real" screen + register uint16 *dp16 = destination_pointer_address; + for (register uint16 i = 0; i < height_desired; ++i) { - // dp is the pointer to a pixel in the "real" screen - register uint16 *dp16 = destination_pointer_address + ( i * screen_pitch_half ); - // sp is the pointer to a pixel in the SDL screen - register uint16 *sp16 = gfx_screen; - // ( i / 2 ) * source_panewidth; "i/2" for doubling lines, aka "deinterlacing" - sp16 += ( ( i >> 1 ) * source_panewidth ); + register uint16 *sp16 = gfx_screen + ( ( i >> 1 ) * source_panewidth ); //since we apply no scaling in X dimension here, we can simply use a single memcpy instead of a for loop memcpy ( dp16, sp16, bytes_per_line ); - //for (register uint16 j = 0; j < Width ; ++j, ++sp16) { - // *dp16++ = *sp16; - //} + + // update the references to display for the next run + dp16 += screen_pitch_half; } // for each height unit } diff --git a/unix/unix.cpp b/unix/unix.cpp index dd15fcc..a7eef55 100644 --- a/unix/unix.cpp +++ b/unix/unix.cpp @@ -1070,7 +1070,8 @@ bool8_32 S9xDeinitUpdate ( int Width, int Height ) { g_fullscreen ? SDL_SWSURFACE|SDL_FULLSCREEN : SDL_SWSURFACE); } - render_x_single_xy((uint16*)(screen -> pixels) /*destination_pointer_address*/, (screen -> pitch) >> 1 /*screen_pitch_half*/, + render_x_single_xy((uint16*)(screen -> pixels) /*destination_pointer_address*/, + (screen -> pitch) >> 1 /*screen_pitch_half*/, (uint16*)(GFX.Screen), source_panewidth, Width, Height); } else