Performance improvies

This commit is contained in:
simon.kagstrom 2009-01-11 14:39:18 +00:00
parent 477fffe52b
commit fb75a3b5a7
4 changed files with 33 additions and 7 deletions

View File

@ -1,4 +1,10 @@
version 3:
* Skip SDL_Delay and SDL_GetTicks() which seem to give strange
results. Use gettime and usleep instead.
* Improve performance a bit more by doing a custom
blit-to-double-size implementation
* Fixed changelog format
* Bought a Classic controller and fixed so that it actually works...

View File

@ -26,7 +26,7 @@ INCLUDES :=
#---------------------------------------------------------------------------------
PCFLAGS = -DPRECISE_CPU_CYCLES=1 -DPRECISE_CIA_CYCLES=1 -DPC_IS_POINTER=0
CFLAGS = -O2 -g -Wall $(MACHDEP) $(INCLUDE) -I$(DEVKITPRO)/SDL/include -U__unix -DHAVE_SDL
CFLAGS = -O3 -g -Wall $(MACHDEP) $(INCLUDE) -I$(DEVKITPRO)/SDL/include -U__unix -DHAVE_SDL
CXXFLAGS = $(CFLAGS)
LDFLAGS = -L$(DEVKITPRO)/SDL/lib -g $(MACHDEP) -Wl,-Map,$(notdir $@).map

View File

@ -12,6 +12,7 @@
#if defined(GEKKO)
#include <wiiuse/wpad.h>
#include <ogc/lwp_watchdog.h>
#define FONT_PATH "/apps/frodo/FreeMono.ttf"
#define SAVES_PATH "/apps/frodo/saves"
#define IMAGE_PATH "/apps/frodo/images"
@ -22,7 +23,7 @@
#define IMAGE_PATH "images"
#define TMP_PATH "tmp"
#endif
#define MS_PER_FRAME 27
#define MS_PER_FRAME 38
static struct timeval tv_start;
static int MENU_SIZE_X, MENU_SIZE_Y;
@ -578,10 +579,14 @@ void C64::VBlank(bool draw_frame)
}
/* From Acorn port */
static uint64_t lastFrame;
#if defined(GEKKO)
uint32_t now = ticks_to_millisecs(gettime());
#else
uint32_t now = SDL_GetTicks();
#endif
if ( (now - lastFrame) < MS_PER_FRAME ) {
SDL_Delay( MS_PER_FRAME - (now - lastFrame) );
usleep( (MS_PER_FRAME - (now - lastFrame)) * 1000);
}
lastFrame = now;
}

View File

@ -11,7 +11,6 @@
#include <SDL.h>
// Display surface
SDL_Surface *screen = NULL;
SDL_Surface *real_screen = NULL;
@ -161,17 +160,33 @@ void C64Display::Update(void)
if (ThePrefs.DisplayOption == 0) {
const int x_border = (DISPLAY_X - FULL_DISPLAY_X / 2) / 2;
const int y_border = (DISPLAY_Y - FULL_DISPLAY_Y / 2) / 2;
Uint8 *src_pixels = (Uint8*)screen->pixels;
Uint8 *dst_pixels = (Uint8*)real_screen->pixels;
const Uint16 src_pitch = screen->pitch;
const Uint16 dst_pitch = real_screen->pitch;
/* Center, double size */
srcrect = (SDL_Rect){x_border, y_border, FULL_DISPLAY_X / 2, FULL_DISPLAY_Y / 2};
dstrect = (SDL_Rect){0, 0, FULL_DISPLAY_X, FULL_DISPLAY_Y};
for (int y = y_border; y < (FULL_DISPLAY_Y/2) + y_border; y++)
{
for (int x = x_border; x < (FULL_DISPLAY_X / 2 + x_border); x++)
{
int src_off = y * src_pitch + x;
int dst_off = (y * 2 - y_border * 2) * dst_pitch + (x * 2 - x_border * 2);
Uint8 v = src_pixels[src_off];
dst_pixels[ dst_off ] = v;
dst_pixels[ dst_off + 1 ] = v;
dst_pixels[ dst_off + dst_pitch ] = v;
dst_pixels[ dst_off + dst_pitch + 1] = v;
}
}
}
else {
/* Stretch */
srcrect = (SDL_Rect){0, 0, DISPLAY_X, DISPLAY_Y};
dstrect = (SDL_Rect){0, 0, FULL_DISPLAY_X, FULL_DISPLAY_Y};
SDL_SoftStretch(screen, &srcrect, real_screen, &dstrect);
}
SDL_SoftStretch(screen, &srcrect, real_screen, &dstrect);
SDL_Flip(real_screen);
}