Skip to content

Commit

Permalink
slight cleanup of the rendering code and some (minimal) speed
Browse files Browse the repository at this point in the history
improvement for hardware scaled as well as "high res" mode in 2x2 no-AA
  • Loading branch information
ivanovic committed Dec 13, 2011
1 parent b026090 commit 5883cd9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
40 changes: 19 additions & 21 deletions unix/pandora_scaling/simple_noAA_scaler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,41 @@

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
}

void render_x_single(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 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
}

Expand Down
3 changes: 2 additions & 1 deletion unix/unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5883cd9

Please sign in to comment.