minor drawing code cleanup

This commit is contained in:
notaz 2013-07-28 00:49:35 +03:00
parent 19886062f1
commit 41946d7023
14 changed files with 23 additions and 58 deletions

View file

@ -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) void FinalizeLine32xRGB555(int sh, int line)
{ {
unsigned short *pd = DrawLineDest; 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 #ifdef _ASM_32X_DRAW
extern void *Pico32xNativePal; extern void *Pico32xNativePal;
Pico32xNativePal = Pico32xMem->pal_native; Pico32xNativePal = Pico32xMem->pal_native;
#endif #endif
if (is_on) { if (which == PDF_RGB555 && use_32x_line_mode) {
// use the same layout as alt renderer // we'll draw via FinalizeLine32xRGB555 (rare)
PicoDrawSetInternalBuf(PicoDraw2FB, 328);
Pico32xDrawMode = only_32x ? PDM32X_32X_ONLY : PDM32X_BOTH;
} else {
PicoDrawSetInternalBuf(NULL, 0); PicoDrawSetInternalBuf(NULL, 0);
Pico32xDrawMode = PDM32X_OFF; 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

View file

@ -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) switch (which)
{ {
@ -1555,7 +1555,7 @@ void PicoDrawSetOutFormat(pdso_t which, int allow_32x)
break; break;
case PDF_RGB555: case PDF_RGB555:
if ((PicoAHW & PAHW_32X) && allow_32x) if ((PicoAHW & PAHW_32X) && use_32x_line_mode)
FinalizeLine = FinalizeLine32xRGB555; FinalizeLine = FinalizeLine32xRGB555;
else else
FinalizeLine = FinalizeLine555; FinalizeLine = FinalizeLine555;
@ -1565,6 +1565,7 @@ void PicoDrawSetOutFormat(pdso_t which, int allow_32x)
FinalizeLine = NULL; FinalizeLine = NULL;
break; break;
} }
PicoDrawSetOutFormat32x(which, use_32x_line_mode);
PicoDrawSetOutputMode4(which); PicoDrawSetOutputMode4(which);
rendstatus_old = -1; rendstatus_old = -1;
} }

View file

@ -15,8 +15,6 @@
#define TILE_ROWS END_ROW-START_ROW #define TILE_ROWS END_ROW-START_ROW
#define USE_CACHE
// note: this is not implemented in ARM asm // note: this is not implemented in ARM asm
#if defined(DRAW2_OVERRIDE_LINE_WIDTH) #if defined(DRAW2_OVERRIDE_LINE_WIDTH)
#define LINE_WIDTH DRAW2_OVERRIDE_LINE_WIDTH #define LINE_WIDTH DRAW2_OVERRIDE_LINE_WIDTH
@ -24,6 +22,9 @@
#define LINE_WIDTH 328 #define LINE_WIDTH 328
#endif #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 HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers
static int HighCache2B[41*(TILE_ROWS+1)+1+1]; static int HighCache2B[41*(TILE_ROWS+1)+1+1];

View file

@ -171,7 +171,7 @@ typedef enum
PDF_RGB555, // RGB/BGR output, depends on compile options PDF_RGB555, // RGB/BGR output, depends on compile options
PDF_8BIT, // 8-bit out (handles shadow/hilight mode, sonic water) PDF_8BIT, // 8-bit out (handles shadow/hilight mode, sonic water)
} pdso_t; } 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 PicoDrawSetOutBuf(void *dest, int increment);
void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num)); void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num));
extern void *DrawLineDest; extern void *DrawLineDest;
@ -216,9 +216,6 @@ extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to us
void Pico32xSetClocks(int msh2_hz, int ssh2_hz); void Pico32xSetClocks(int msh2_hz, int ssh2_hz);
// 32x/draw.c
void PicoDraw32xSetFrameMode(int is_on, int only_32x);
#else #else
#define Pico32xSetClocks(msh2_khz, ssh2_khz) #define Pico32xSetClocks(msh2_khz, ssh2_khz)

View file

@ -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); void p32x_sh2_poll_event(SH2 *sh2, unsigned int flags, unsigned int m68k_cycles);
// 32x/draw.c // 32x/draw.c
void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode);
void FinalizeLine32xRGB555(int sh, int line); void FinalizeLine32xRGB555(int sh, int line);
void PicoDraw32xLayer(int offs, int lines, int mdbg); void PicoDraw32xLayer(int offs, int lines, int mdbg);
void PicoDraw32xLayerMdOnly(int offs, int lines); void PicoDraw32xLayerMdOnly(int offs, int lines);
@ -784,7 +785,6 @@ void p32x_pwm_schedule_sh2(SH2 *sh2);
#define PicoFrame32x() #define PicoFrame32x()
#define PicoUnload32x() #define PicoUnload32x()
#define Pico32xStateLoaded() #define Pico32xStateLoaded()
#define PicoDraw32xSetFrameMode(...)
#define FinalizeLine32xRGB555 NULL #define FinalizeLine32xRGB555 NULL
#define p32x_pwm_update(...) #define p32x_pwm_update(...)
#define p32x_timers_recalc() #define p32x_timers_recalc()

View file

@ -17,10 +17,6 @@
#include "input_pico.h" #include "input_pico.h"
#include "version.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 void *shadow_fb;
static const struct in_default_bind in_sdl_defbinds[] = { static const struct in_default_bind in_sdl_defbinds[] = {

View file

@ -26,7 +26,6 @@
// main 300K gfx-related buffer. Used by menu and renderers. // main 300K gfx-related buffer. Used by menu and renderers.
unsigned char gfx_buffer[321*240*2*2]; 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 short *snd_cbuff = NULL;
static int snd_cbuf_samples = 0, snd_all_samples = 0; static int snd_cbuf_samples = 0, snd_all_samples = 0;

View file

@ -43,8 +43,6 @@
extern int crashed_940; extern int crashed_940;
static short __attribute__((aligned(4))) sndBuffer[2*(44100+100)/50]; 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; static int osd_fps_x, osd_y, doing_bg_frame;
const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL }; const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };
const char *renderer_names32x[] = { "accurate", "faster", "fastest", 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 // Wiz 16bit is an exception, uses line rendering due to rotation mess
if (renderer == RT_16BIT && (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)) { if (renderer == RT_16BIT && (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)) {
PicoDrawSetOutFormat(PDF_RGB555, 1); PicoDrawSetOutFormat(PDF_RGB555, 1);
PicoDraw32xSetFrameMode(0, 0);
} }
else { else {
PicoDrawSetOutFormat(PDF_NONE, 0); PicoDrawSetOutFormat(PDF_NONE, 0);
PicoDraw32xSetFrameMode(1, 0);
} }
PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
gp2x_mode = 16; gp2x_mode = 16;
@ -785,7 +781,6 @@ void pemu_forced_frame(int no_scale, int do_emu)
{ {
doing_bg_frame = 1; doing_bg_frame = 1;
PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
PicoDraw32xSetFrameMode(0, 0);
PicoDrawSetCallbacks(NULL, NULL); PicoDrawSetCallbacks(NULL, NULL);
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;

View file

@ -40,10 +40,6 @@ static int vout_width, vout_height;
static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; 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); static void snd_write(int len);
#ifdef _WIN32 #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) void emu_32x_startup(void)
{ {
PicoDrawSetOutFormat(PDF_RGB555, 1);
} }
#ifndef ANDROID #ifndef ANDROID
@ -614,7 +609,7 @@ void retro_init(void)
vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2);
PicoInit(); PicoInit();
PicoDrawSetOutFormat(PDF_RGB555, 1); PicoDrawSetOutFormat(PDF_RGB555, 0);
PicoDrawSetOutBuf(vout_buf, vout_width * 2); PicoDrawSetOutBuf(vout_buf, vout_width * 2);
//PicoMessage = plat_status_msg_busy_next; //PicoMessage = plat_status_msg_busy_next;

View file

@ -142,18 +142,9 @@ static void apply_renderer(void)
break; break;
} }
if (PicoAHW & PAHW_32X) { 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);
PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); 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) 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) void pemu_forced_frame(int no_scale, int do_emu)
{ {
PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
PicoDraw32xSetFrameMode(0, 0);
PicoDrawSetCallbacks(NULL, NULL); PicoDrawSetCallbacks(NULL, NULL);
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;

View file

@ -18,7 +18,6 @@
#include "log_io.h" #include "log_io.h"
int current_keys; int current_keys;
unsigned char *PicoDraw2FB;
#ifdef FBDEV #ifdef FBDEV
@ -265,7 +264,6 @@ static void realloc_screen(void)
g_menubg_ptr = realloc(g_menubg_ptr, size); g_menubg_ptr = realloc(g_menubg_ptr, size);
memset(g_screen_ptr, 0, size); memset(g_screen_ptr, 0, size);
memset(g_menubg_ptr, 0, size); memset(g_menubg_ptr, 0, size);
PicoDraw2FB = g_menubg_ptr;
scr_changed = 0; scr_changed = 0;
} }
@ -335,7 +333,6 @@ void plat_init(void)
g_screen_width = g_menuscreen_w = w; g_screen_width = g_menuscreen_w = w;
g_screen_height = g_menuscreen_h = h; g_screen_height = g_menuscreen_h = h;
g_menubg_ptr = realloc(g_menubg_ptr, w * g_screen_height * 2); g_menubg_ptr = realloc(g_menubg_ptr, w * g_screen_height * 2);
PicoDraw2FB = g_menubg_ptr;
#else #else
realloc_screen(); realloc_screen();
memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);

View file

@ -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 const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
static unsigned char __attribute__((aligned(4))) fb_copy[320 * 240 * 2]; static unsigned char __attribute__((aligned(4))) fb_copy[320 * 240 * 2];
static void *temp_frame; static void *temp_frame;
unsigned char *PicoDraw2FB;
const char *renderer_names[] = { NULL }; const char *renderer_names[] = { NULL };
const char *renderer_names32x[] = { 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) void pemu_finalize_frame(const char *fps, const char *notice)
{ {
if (notice && notice[0]) if (notice && notice[0])
@ -160,6 +152,7 @@ void pemu_finalize_frame(const char *fps, const char *notice)
void plat_video_flip(void) void plat_video_flip(void)
{ {
g_screen_ptr = vout_fbdev_flip(layer_fb); 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.. // XXX: drain OS event queue here, maybe we'll actually use it someday..
xenv_update(NULL, NULL, NULL, NULL); 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; return;
PicoDrawSetOutFormat(PDF_RGB555, 1); PicoDrawSetOutFormat(PDF_RGB555, 1);
PicoDrawSetCallbacks(emuscan, NULL); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
if (is_32cols) { if (is_32cols) {
fb_w = 256; fb_w = 256;
@ -474,7 +467,6 @@ void plat_init(void)
} }
g_menubg_ptr = temp_frame; g_menubg_ptr = temp_frame;
g_menubg_src_ptr = temp_frame; g_menubg_src_ptr = temp_frame;
PicoDraw2FB = temp_frame;
pnd_menu_init(); pnd_menu_init();

View file

@ -36,7 +36,7 @@ int sceAudio_E0727056(int volume, void *buffer); // blocking output
int sceAudioOutput2GetRestSample(); 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; int engineStateSuspend;
#define PICO_PEN_ADJUST_X 4 #define PICO_PEN_ADJUST_X 4

View file

@ -18,8 +18,6 @@
#include "main.h" #include "main.h"
static unsigned short screen_buff[320 * 240]; 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_names[] = { NULL };
const char *renderer_names32x[] = { NULL }; const char *renderer_names32x[] = { NULL };