瀏覽代碼

frontend: eliminate osd_text dupes

not only dupe code is bad, it's crasing too
notaz 10 年之前
父節點
當前提交
f7e40c9b2e
共有 5 個文件被更改,包括 26 次插入75 次删除
  1. 19 1
      platform/common/emu.c
  2. 2 0
      platform/common/emu.h
  3. 1 16
      platform/gp2x/emu.c
  4. 2 38
      platform/linux/emu.c
  5. 2 20
      platform/pandora/plat.c

+ 19 - 1
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) {

+ 2 - 0
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);

+ 1 - 16
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;
 

+ 2 - 38
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)

+ 2 - 20
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();
 }