X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=frontend%2Fplugin_lib.c;h=a0f16e9324ff30f755b3aa4e96192fb4e1d0df26;hp=6cce912141c82989abd0eb3fd78d1b271bb7653e;hb=b2058a5bead44a5b5ecaa903e9bbf3231477fde9;hpb=841ba5ee5bfeb32bb1194c423a047f98825d26fd diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 6cce9121..a0f16e93 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -31,6 +31,7 @@ #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../libpcsxcore/psemu_plugin_defs.h" #include "../plugins/gpulib/cspace.h" +#include "../plugins/dfinput/externals.h" int in_type1, in_type2; int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; @@ -48,6 +49,12 @@ static int vsync_cnt; static int is_pal, frame_interval, frame_interval1024; static int vsync_usec_time; +// platform hooks +void (*pl_plat_clear)(void); +void (*pl_plat_blit)(int doffs, const void *src, int w, int h, + int sstride, int bgr24); +void (*pl_plat_hud_print)(int x, int y, const char *str, int bpp); + static __attribute__((noinline)) int get_cpu_ticks(void) { @@ -65,31 +72,48 @@ static __attribute__((noinline)) int get_cpu_ticks(void) sscanf(buf, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %lu", &utime); ret = utime - last_utime; + if (ret > 200) + ret = 0; last_utime = utime; return ret; } +static void hud_print(void *fb, int w, int x, int y, const char *text) +{ + if (pl_plat_hud_print) + pl_plat_hud_print(x, y, text, pl_vout_bpp); + else if (pl_vout_bpp == 16) + basic_text_out16_nf(fb, w, x, y, text); +} + +static void hud_printf(void *fb, int w, int x, int y, const char *texto, ...) +{ + va_list args; + char buffer[256]; + + va_start(args, texto); + vsnprintf(buffer, sizeof(buffer), texto, args); + va_end(args); + + hud_print(fb, w, x, y, buffer); +} + static void print_msg(int h, int border) { - if (pl_vout_bpp == 16) - basic_text_out16_nf(pl_vout_buf, pl_vout_w, - border + 2, h - 10, hud_msg); + hud_print(pl_vout_buf, pl_vout_w, border + 2, h - 10, hud_msg); } static void print_fps(int h, int border) { - if (pl_vout_bpp == 16) - basic_text_out16(pl_vout_buf, pl_vout_w, - border + 2, h - 10, "%2d %4.1f", - pl_rearmed_cbs.flips_per_sec, pl_rearmed_cbs.vsps_cur); + hud_printf(pl_vout_buf, pl_vout_w, border + 2, h - 10, + "%2d %4.1f", pl_rearmed_cbs.flips_per_sec, + pl_rearmed_cbs.vsps_cur); } static void print_cpu_usage(int w, int h, int border) { - if (pl_vout_bpp == 16) - basic_text_out16(pl_vout_buf, pl_vout_w, - pl_vout_w - border - 28, h - 10, - "%3d", pl_rearmed_cbs.cpu_usage); + hud_printf(pl_vout_buf, pl_vout_w, pl_vout_w - border - 28, h - 10, + "%3d", pl_rearmed_cbs.cpu_usage); } // draw 192x8 status of 24 sound channels @@ -105,7 +129,7 @@ static __attribute__((noinline)) void draw_active_chans(int vout_w, int vout_h) unsigned short *d, p; int c, x, y; - if (pl_vout_bpp != 16) + if (dest == NULL || pl_vout_bpp != 16) return; spu_get_debug_info(&live_chans, &run_chans, &fmod_chans, &noise_chans); @@ -199,7 +223,7 @@ static int resolution_ok(int w, int h) return w <= 1024 && h <= 512; } -static void pl_vout_set_mode(int w, int h, int bpp) +static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp) { int vout_w, vout_h, vout_bpp; @@ -209,8 +233,10 @@ static void pl_vout_set_mode(int w, int h, int bpp) h = (h + 7) & ~7; vsync_cnt_ms_prev = vsync_cnt; - vout_w = psx_w = w; - vout_h = psx_h = h; + psx_w = raw_w; + psx_h = raw_h; + vout_w = w; + vout_h = h; vout_bpp = psx_bpp = bpp; pl_vout_scale = 1; @@ -235,9 +261,9 @@ static void pl_vout_set_mode(int w, int h, int bpp) update_layer_size(vout_w, vout_h); pl_vout_buf = plat_gvideo_set_mode(&vout_w, &vout_h, &vout_bpp); - if (pl_vout_buf == NULL) + if (pl_vout_buf == NULL && pl_plat_blit == NULL) fprintf(stderr, "failed to set mode %dx%d@%d\n", - psx_w, psx_h, psx_bpp); + vout_w, vout_h, psx_bpp); else { pl_vout_w = vout_w; pl_vout_h = vout_h; @@ -257,28 +283,43 @@ static void pl_vout_flip(const void *vram, int stride, int bgr24, int w, int h) pcnt_start(PCNT_BLIT); - if (dest == NULL) - goto out; - if (vram == NULL) { // blanking - memset(pl_vout_buf, 0, dstride * pl_vout_h * pl_vout_bpp / 8); - goto out; + if (pl_plat_clear) + pl_plat_clear(); + else + memset(pl_vout_buf, 0, + dstride * pl_vout_h * pl_vout_bpp / 8); + goto out_hud; } // borders doffs = (dstride - w * pl_vout_scale) / 2 & ~1; - dest += doffs * 2; if (doffs > doffs_old) clear_counter = 2; doffs_old = doffs; if (clear_counter > 0) { - memset(pl_vout_buf, 0, dstride * pl_vout_h * pl_vout_bpp / 8); + if (pl_plat_clear) + pl_plat_clear(); + else + memset(pl_vout_buf, 0, + dstride * pl_vout_h * pl_vout_bpp / 8); clear_counter--; } + if (pl_plat_blit) + { + pl_plat_blit(doffs, src, w, h, stride, bgr24); + goto out_hud; + } + + if (dest == NULL) + goto out; + + dest += doffs * 2; + if (bgr24) { if (pl_rearmed_cbs.only_16bpp) { @@ -301,12 +342,12 @@ static void pl_vout_flip(const void *vram, int stride, int bgr24, int w, int h) else if (soft_filter == SOFT_FILTER_SCALE2X && pl_vout_scale == 2) { neon_scale2x_16_16(src, (void *)dest, w, - stride * 2, dstride * 2, h1); + stride * 2, dstride * 2, h); } else if (soft_filter == SOFT_FILTER_EAGLE2X && pl_vout_scale == 2) { neon_eagle2x_16_16(src, (void *)dest, w, - stride * 2, dstride * 2, h1); + stride * 2, dstride * 2, h); } #endif else @@ -317,6 +358,7 @@ static void pl_vout_flip(const void *vram, int stride, int bgr24, int w, int h) } } +out_hud: pl_print_hud(w * pl_vout_scale, h * pl_vout_scale, 0); out: @@ -390,7 +432,7 @@ int dispmode_doubleres(void) int dispmode_scale2x(void) { - if (psx_bpp != 16) + if (!resolution_ok(psx_w * 2, psx_h * 2) || psx_bpp != 16) return 0; dispmode_default(); @@ -401,7 +443,7 @@ int dispmode_scale2x(void) int dispmode_eagle2x(void) { - if (psx_bpp != 16) + if (!resolution_ok(psx_w * 2, psx_h * 2) || psx_bpp != 16) return 0; dispmode_default(); @@ -441,7 +483,7 @@ void pl_switch_dispmode(void) * more square-like analogs in PSX */ static void update_analog_nub_adjust(int *x_, int *y_) { - const int d = 16; + #define d 16 static const int scale[] = { 0 - d*2, 0 - d*2, 0 - d*2, 12 - d*2, 30 - d*2, 60 - d*2, 75 - d*2, 60 - d*2, 60 - d*2 }; @@ -463,6 +505,7 @@ static void update_analog_nub_adjust(int *x_, int *y_) *x_ = x; *y_ = y; + #undef d } static void update_analogs(void) @@ -526,13 +569,13 @@ static void update_input(void) } #endif -void pl_update_gun(int *xn, int *xres, int *y, int *in) +void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in) { if (tsdev) - pl_gun_ts_update(tsdev, xn, y, in); + pl_gun_ts_update(tsdev, xn, yn, in); - *xres = pl_vout_w; - *y = *y * pl_vout_h >> 10; + *xres = psx_w; + *yres = psx_h; } #define MAX_LAG_FRAMES 3