From 41946d7023cded9999495eb8916eeb5ab0480a1f Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 28 Jul 2013 00:49:35 +0300 Subject: [PATCH] minor drawing code cleanup --- pico/32x/draw.c | 16 ++++++++++------ pico/draw.c | 5 +++-- pico/draw2.c | 5 +++-- pico/pico.h | 5 +---- pico/pico_int.h | 2 +- platform/common/plat_sdl.c | 4 ---- platform/gizmondo/emu.c | 1 - platform/gp2x/emu.c | 5 ----- platform/libretro.c | 7 +------ platform/linux/emu.c | 12 +----------- platform/linux/io.c | 3 --- platform/pandora/plat.c | 12 ++---------- platform/psp/emu.c | 2 +- platform/win32/plat.c | 2 -- 14 files changed, 23 insertions(+), 58 deletions(-) diff --git a/pico/32x/draw.c b/pico/32x/draw.c index 66814abd..33947e6b 100644 --- a/pico/32x/draw.c +++ b/pico/32x/draw.c @@ -82,6 +82,7 @@ static void convert_pal555(int invert_prio) } \ } +// this is almost never used (Wiz and menu bg gen only) void FinalizeLine32xRGB555(int sh, int line) { unsigned short *pd = DrawLineDest; @@ -306,20 +307,23 @@ void PicoDraw32xLayerMdOnly(int offs, int lines) } } -void PicoDraw32xSetFrameMode(int is_on, int only_32x) +void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode) { #ifdef _ASM_32X_DRAW extern void *Pico32xNativePal; Pico32xNativePal = Pico32xMem->pal_native; #endif - if (is_on) { - // use the same layout as alt renderer - PicoDrawSetInternalBuf(PicoDraw2FB, 328); - Pico32xDrawMode = only_32x ? PDM32X_32X_ONLY : PDM32X_BOTH; - } else { + if (which == PDF_RGB555 && use_32x_line_mode) { + // we'll draw via FinalizeLine32xRGB555 (rare) PicoDrawSetInternalBuf(NULL, 0); Pico32xDrawMode = PDM32X_OFF; + return; } + + // use the same layout as alt renderer + PicoDrawSetInternalBuf(PicoDraw2FB, 328); + Pico32xDrawMode = (which == PDF_RGB555) ? PDM32X_32X_ONLY : PDM32X_BOTH; } +// vim:shiftwidth=2:ts=2:expandtab diff --git a/pico/draw.c b/pico/draw.c index d14e9968..11cd8204 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1546,7 +1546,7 @@ void PicoDrawUpdateHighPal(void) } } -void PicoDrawSetOutFormat(pdso_t which, int allow_32x) +void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode) { switch (which) { @@ -1555,7 +1555,7 @@ void PicoDrawSetOutFormat(pdso_t which, int allow_32x) break; case PDF_RGB555: - if ((PicoAHW & PAHW_32X) && allow_32x) + if ((PicoAHW & PAHW_32X) && use_32x_line_mode) FinalizeLine = FinalizeLine32xRGB555; else FinalizeLine = FinalizeLine555; @@ -1565,6 +1565,7 @@ void PicoDrawSetOutFormat(pdso_t which, int allow_32x) FinalizeLine = NULL; break; } + PicoDrawSetOutFormat32x(which, use_32x_line_mode); PicoDrawSetOutputMode4(which); rendstatus_old = -1; } diff --git a/pico/draw2.c b/pico/draw2.c index 58139d93..ae69b52d 100644 --- a/pico/draw2.c +++ b/pico/draw2.c @@ -15,8 +15,6 @@ #define TILE_ROWS END_ROW-START_ROW -#define USE_CACHE - // note: this is not implemented in ARM asm #if defined(DRAW2_OVERRIDE_LINE_WIDTH) #define LINE_WIDTH DRAW2_OVERRIDE_LINE_WIDTH @@ -24,6 +22,9 @@ #define LINE_WIDTH 328 #endif +static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; +unsigned char *PicoDraw2FB = PicoDraw2FB_; + static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers static int HighCache2B[41*(TILE_ROWS+1)+1+1]; diff --git a/pico/pico.h b/pico/pico.h index 667b6c25..4a99ef57 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -171,7 +171,7 @@ typedef enum PDF_RGB555, // RGB/BGR output, depends on compile options PDF_8BIT, // 8-bit out (handles shadow/hilight mode, sonic water) } pdso_t; -void PicoDrawSetOutFormat(pdso_t which, int allow_32x); +void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode); void PicoDrawSetOutBuf(void *dest, int increment); void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num)); extern void *DrawLineDest; @@ -216,9 +216,6 @@ extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to us void Pico32xSetClocks(int msh2_hz, int ssh2_hz); -// 32x/draw.c -void PicoDraw32xSetFrameMode(int is_on, int only_32x); - #else #define Pico32xSetClocks(msh2_khz, ssh2_khz) diff --git a/pico/pico_int.h b/pico/pico_int.h index bfdf73ae..c350fa2c 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -757,6 +757,7 @@ void p32x_m68k_poll_event(unsigned int flags); void p32x_sh2_poll_event(SH2 *sh2, unsigned int flags, unsigned int m68k_cycles); // 32x/draw.c +void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode); void FinalizeLine32xRGB555(int sh, int line); void PicoDraw32xLayer(int offs, int lines, int mdbg); void PicoDraw32xLayerMdOnly(int offs, int lines); @@ -784,7 +785,6 @@ void p32x_pwm_schedule_sh2(SH2 *sh2); #define PicoFrame32x() #define PicoUnload32x() #define Pico32xStateLoaded() -#define PicoDraw32xSetFrameMode(...) #define FinalizeLine32xRGB555 NULL #define p32x_pwm_update(...) #define p32x_timers_recalc() diff --git a/platform/common/plat_sdl.c b/platform/common/plat_sdl.c index 94f6e6ec..600af45a 100644 --- a/platform/common/plat_sdl.c +++ b/platform/common/plat_sdl.c @@ -17,10 +17,6 @@ #include "input_pico.h" #include "version.h" -// FIXME: these 2 shouldn't be here -static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; -unsigned char *PicoDraw2FB = PicoDraw2FB_; - static void *shadow_fb; static const struct in_default_bind in_sdl_defbinds[] = { diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index 2844fb25..3115ebd3 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -26,7 +26,6 @@ // main 300K gfx-related buffer. Used by menu and renderers. unsigned char gfx_buffer[321*240*2*2]; -unsigned char *PicoDraw2FB = gfx_buffer; // temporary buffer for alt renderer ( (8+320)*(8+240+8) ) static short *snd_cbuff = NULL; static int snd_cbuf_samples = 0, snd_all_samples = 0; diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index df9faac8..825ab5bb 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -43,8 +43,6 @@ extern int crashed_940; static short __attribute__((aligned(4))) sndBuffer[2*(44100+100)/50]; -static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; -unsigned char *PicoDraw2FB = PicoDraw2FB_; static int osd_fps_x, osd_y, doing_bg_frame; const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL }; const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL }; @@ -524,11 +522,9 @@ static void vid_reset_mode(void) // Wiz 16bit is an exception, uses line rendering due to rotation mess if (renderer == RT_16BIT && (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)) { PicoDrawSetOutFormat(PDF_RGB555, 1); - PicoDraw32xSetFrameMode(0, 0); } else { PicoDrawSetOutFormat(PDF_NONE, 0); - PicoDraw32xSetFrameMode(1, 0); } PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); gp2x_mode = 16; @@ -785,7 +781,6 @@ void pemu_forced_frame(int no_scale, int do_emu) { doing_bg_frame = 1; PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); - PicoDraw32xSetFrameMode(0, 0); PicoDrawSetCallbacks(NULL, NULL); Pico.m.dirtyPal = 1; diff --git a/platform/libretro.c b/platform/libretro.c index ecf6a293..15a83bad 100644 --- a/platform/libretro.c +++ b/platform/libretro.c @@ -40,10 +40,6 @@ static int vout_width, vout_height; static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; -// FIXME: these 2 shouldn't be here -static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; -unsigned char *PicoDraw2FB = PicoDraw2FB_; - static void snd_write(int len); #ifdef _WIN32 @@ -151,7 +147,6 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols) void emu_32x_startup(void) { - PicoDrawSetOutFormat(PDF_RGB555, 1); } #ifndef ANDROID @@ -614,7 +609,7 @@ void retro_init(void) vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); PicoInit(); - PicoDrawSetOutFormat(PDF_RGB555, 1); + PicoDrawSetOutFormat(PDF_RGB555, 0); PicoDrawSetOutBuf(vout_buf, vout_width * 2); //PicoMessage = plat_status_msg_busy_next; diff --git a/platform/linux/emu.c b/platform/linux/emu.c index d060e9f2..b99c4a6e 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -142,17 +142,8 @@ static void apply_renderer(void) break; } - if (PicoAHW & PAHW_32X) { - int only_32x = 0; - if (currentConfig.renderer == RT_16BIT) - only_32x = 1; - else - PicoDrawSetOutFormat(PDF_NONE, 0); - PicoDraw32xSetFrameMode(1, only_32x); + if (PicoAHW & PAHW_32X) PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); - } - //PicoDraw32xSetFrameMode(0, 0); - //PicoDrawSetOutFormat(PDF_RGB555, 1); } void plat_video_toggle_renderer(int change, int is_menu) @@ -198,7 +189,6 @@ void plat_update_volume(int has_changed, int is_up) void pemu_forced_frame(int no_scale, int do_emu) { PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); - PicoDraw32xSetFrameMode(0, 0); PicoDrawSetCallbacks(NULL, NULL); Pico.m.dirtyPal = 1; diff --git a/platform/linux/io.c b/platform/linux/io.c index 1b912c98..13d6d9ab 100644 --- a/platform/linux/io.c +++ b/platform/linux/io.c @@ -18,7 +18,6 @@ #include "log_io.h" int current_keys; -unsigned char *PicoDraw2FB; #ifdef FBDEV @@ -265,7 +264,6 @@ static void realloc_screen(void) g_menubg_ptr = realloc(g_menubg_ptr, size); memset(g_screen_ptr, 0, size); memset(g_menubg_ptr, 0, size); - PicoDraw2FB = g_menubg_ptr; scr_changed = 0; } @@ -335,7 +333,6 @@ void plat_init(void) g_screen_width = g_menuscreen_w = w; g_screen_height = g_menuscreen_h = h; g_menubg_ptr = realloc(g_menubg_ptr, w * g_screen_height * 2); - PicoDraw2FB = g_menubg_ptr; #else realloc_screen(); memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); diff --git a/platform/pandora/plat.c b/platform/pandora/plat.c index 49b8da6b..72c63aa3 100644 --- a/platform/pandora/plat.c +++ b/platform/pandora/plat.c @@ -43,7 +43,6 @@ static int g_osd_fps_x, g_osd_y, doing_bg_frame; static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts"; static unsigned char __attribute__((aligned(4))) fb_copy[320 * 240 * 2]; static void *temp_frame; -unsigned char *PicoDraw2FB; const char *renderer_names[] = { NULL }; const char *renderer_names32x[] = { NULL }; @@ -140,13 +139,6 @@ static void draw_cd_leds(void) } } -static int emuscan(unsigned int num) -{ - DrawLineDest = (unsigned short *)g_screen_ptr + num * g_screen_width; - - return 0; -} - void pemu_finalize_frame(const char *fps, const char *notice) { if (notice && notice[0]) @@ -160,6 +152,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) void plat_video_flip(void) { g_screen_ptr = vout_fbdev_flip(layer_fb); + PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); // XXX: drain OS event queue here, maybe we'll actually use it someday.. xenv_update(NULL, NULL, NULL, NULL); @@ -308,7 +301,7 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols) return; PicoDrawSetOutFormat(PDF_RGB555, 1); - PicoDrawSetCallbacks(emuscan, NULL); + PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); if (is_32cols) { fb_w = 256; @@ -474,7 +467,6 @@ void plat_init(void) } g_menubg_ptr = temp_frame; g_menubg_src_ptr = temp_frame; - PicoDraw2FB = temp_frame; pnd_menu_init(); diff --git a/platform/psp/emu.c b/platform/psp/emu.c index c58fc17b..5a2e8809 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -36,7 +36,7 @@ int sceAudio_E0727056(int volume, void *buffer); // blocking output int sceAudioOutput2GetRestSample(); -unsigned char *PicoDraw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword.. +//unsigned char *PicoDraw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword.. int engineStateSuspend; #define PICO_PEN_ADJUST_X 4 diff --git a/platform/win32/plat.c b/platform/win32/plat.c index 7ee685ef..aa3a7f21 100644 --- a/platform/win32/plat.c +++ b/platform/win32/plat.c @@ -18,8 +18,6 @@ #include "main.h" static unsigned short screen_buff[320 * 240]; -static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; -unsigned char *PicoDraw2FB = PicoDraw2FB_; const char *renderer_names[] = { NULL }; const char *renderer_names32x[] = { NULL }; -- 2.39.5