From f7e40c9b2e6d5ca446cb8c2edf9e7601dd9c97cd Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 12 Oct 2013 22:05:04 +0300 Subject: [PATCH] frontend: eliminate osd_text dupes not only dupe code is bad, it's crasing too --- platform/common/emu.c | 20 +++++++++++++++++++- platform/common/emu.h | 2 ++ platform/gp2x/emu.c | 17 +---------------- platform/linux/emu.c | 40 ++-------------------------------------- platform/pandora/plat.c | 22 ++-------------------- 5 files changed, 26 insertions(+), 75 deletions(-) diff --git a/platform/common/emu.c b/platform/common/emu.c index 88fefd5..7f375a3 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -738,8 +738,26 @@ mk_text_out(emu_text_out16_rot, unsigned short, 0xffff, #undef mk_text_out +void emu_osd_text16(int x, int y, const char *text) +{ + int len = strlen(text) * 8; + int i, h; + + len++; + if (x + len > g_screen_width) + len = g_screen_width - x; + + for (h = 0; h < 8; h++) { + unsigned short *p; + p = (unsigned short *)g_screen_ptr + + x + g_screen_width * (y + h); + for (i = len; i > 0; i--, p++) + *p = (*p >> 2) & 0x39e7; + } + emu_text_out16(x, y, text); +} -void update_movie(void) +static void update_movie(void) { int offs = Pico.m.frame_count*3 + 0x40; if (offs+3 > movie_size) { diff --git a/platform/common/emu.h b/platform/common/emu.h index 8f8f61f..6e7c399 100644 --- a/platform/common/emu.h +++ b/platform/common/emu.h @@ -129,6 +129,8 @@ void emu_text_out16(int x, int y, const char *text); void emu_text_out8_rot (int x, int y, const char *text); void emu_text_out16_rot(int x, int y, const char *text); +void emu_osd_text16(int x, int y, const char *text); + void emu_make_path(char *buff, const char *end, int size); void emu_update_input(void); void emu_get_game_name(char *str150); diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 74bcbcb..244f15d 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -128,21 +128,6 @@ static void osd_text8(int x, int y, const char *text) emu_text_out8(x, y, text); } -static void osd_text16(int x, int y, const char *text) -{ - int len = strlen(text)*8; - int *p, i, h, offs; - - len = (len+1) >> 1; - for (h = 0; h < 8; h++) { - offs = (x + g_screen_width * (y+h)) & ~1; - p = (int *) ((short *)g_screen_ptr + offs); - for (i = len; i; i--, p++) - *p = (*p >> 2) & 0x39e7; - } - emu_text_out16(x, y, text); -} - static void osd_text8_rot(int x, int y, const char *text) { int len = strlen(text) * 8; @@ -540,7 +525,7 @@ static void vid_reset_mode(void) PicoDrawSetCallbacks(emu_scan_begin, emu_scan_end); if (is_16bit_mode()) - osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text16_rot : osd_text16; + osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text16_rot : emu_osd_text16; else osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text8_rot : osd_text8; diff --git a/platform/linux/emu.c b/platform/linux/emu.c index 9e45fb1..c22f4fd 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -34,41 +34,6 @@ void pemu_validate_config(void) PicoOpt &= ~POPT_EN_DRC; } -// FIXME: dupes from GP2X, need cleanup -static void (*osd_text)(int x, int y, const char *text); - -/* -static void osd_text8(int x, int y, const char *text) -{ - int len = strlen(text)*8; - int *p, i, h, offs; - - len = (len+3) >> 2; - for (h = 0; h < 8; h++) { - offs = (x + g_screen_width * (y+h)) & ~3; - p = (int *) ((char *)g_screen_ptr + offs); - for (i = len; i; i--, p++) - *p = 0xe0e0e0e0; - } - emu_text_out8(x, y, text); -} -*/ - -static void osd_text16(int x, int y, const char *text) -{ - int len = strlen(text)*8; - int *p, i, h, offs; - - len = (len+1) >> 1; - for (h = 0; h < 8; h++) { - offs = (x + g_screen_width * (y+h)) & ~1; - p = (int *) ((short *)g_screen_ptr + offs); - for (i = len; i; i--, p++) - *p = (*p >> 2) & 0x39e7; - } - emu_text_out16(x, y, text); -} - static void draw_cd_leds(void) { int led_reg, pitch, scr_offs, led_offs; @@ -115,9 +80,9 @@ void pemu_finalize_frame(const char *fps, const char *notice) if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) { if (notice) - osd_text(4, g_screen_height - 8, notice); + emu_osd_text16(4, g_screen_height - 8, notice); if (currentConfig.EmuOpt & EOPT_SHOW_FPS) - osd_text(g_screen_width - 60, g_screen_height - 8, fps); + emu_osd_text16(g_screen_width - 60, g_screen_height - 8, fps); } if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) draw_cd_leds(); @@ -215,7 +180,6 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols) void pemu_loop_prep(void) { apply_renderer(); - osd_text = osd_text16; } void pemu_loop_end(void) diff --git a/platform/pandora/plat.c b/platform/pandora/plat.c index f82d702..8f8eac6 100644 --- a/platform/pandora/plat.c +++ b/platform/pandora/plat.c @@ -135,24 +135,6 @@ void pemu_validate_config(void) currentConfig.CPUclock = plat_target_cpu_clock_get(); } -static void osd_text(int x, int y, const char *text) -{ - int len = strlen(text)*8; - int i, h; - - len++; - if (x + len > g_screen_width) - len = g_screen_width - x; - - for (h = 0; h < 8; h++) { - unsigned short *p; - p = (unsigned short *)g_screen_ptr + x + g_screen_width*(y + h); - for (i = len; i > 0; i--, p++) - *p = (*p>>2) & 0x39e7; - } - emu_text_out16(x, y, text); -} - static void draw_cd_leds(void) { int old_reg; @@ -182,9 +164,9 @@ static void draw_cd_leds(void) void pemu_finalize_frame(const char *fps, const char *notice) { if (notice && notice[0]) - osd_text(2, g_osd_y, notice); + emu_osd_text16(2, g_osd_y, notice); if (fps && fps[0] && (currentConfig.EmuOpt & EOPT_SHOW_FPS)) - osd_text(g_osd_fps_x, g_osd_y, fps); + emu_osd_text16(g_osd_fps_x, g_osd_y, fps); if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) draw_cd_leds(); } -- 2.39.2