diff options
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/cspace.c | 177 | ||||
-rw-r--r-- | frontend/cspace.h | 18 | ||||
-rw-r--r-- | frontend/cspace_arm.S | 65 | ||||
-rw-r--r-- | frontend/cspace_neon.s | 165 | ||||
m--------- | frontend/libpicofe | 0 | ||||
-rw-r--r-- | frontend/libretro.c | 2 | ||||
-rw-r--r-- | frontend/main.c | 38 | ||||
-rw-r--r-- | frontend/main.h | 12 | ||||
-rw-r--r-- | frontend/menu.c | 9 | ||||
-rw-r--r-- | frontend/plat_pollux.c | 2 | ||||
-rw-r--r-- | frontend/plat_sdl.c | 46 | ||||
-rw-r--r-- | frontend/plugin_lib.c | 11 | ||||
-rw-r--r-- | frontend/plugin_lib.h | 4 |
13 files changed, 509 insertions, 40 deletions
diff --git a/frontend/cspace.c b/frontend/cspace.c new file mode 100644 index 0000000..33a981d --- /dev/null +++ b/frontend/cspace.c @@ -0,0 +1,177 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2011,2012 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * See the COPYING file in the top-level directory. + */ + +#include "cspace.h" + +/* + * note: these are intended for testing and should be avoided + * in favor of NEON version or platform-specific conversion + */ + +#ifndef __arm__ + +void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) +{ + const unsigned int *src = src_; + unsigned int *dst = dst_; + unsigned int p; + int x; + + for (x = 0; x < bytes / 4; x++) { + p = src[x]; + p = ((p & 0x7c007c00) >> 10) | ((p & 0x03e003e0) << 1) + | ((p & 0x001f001f) << 11); + dst[x] = p; + } +} + +#endif + +#ifndef __ARM_NEON__ + +void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) +{ + const unsigned char *src = src_; + unsigned int *dst = dst_; + unsigned int r1, g1, b1, r2, g2, b2; + + for (; bytes >= 6; bytes -= 6, src += 6, dst++) { + r1 = src[0] & 0xf8; + g1 = src[1] & 0xfc; + b1 = src[2] & 0xf8; + r2 = src[3] & 0xf8; + g2 = src[4] & 0xfc; + b2 = src[5] & 0xf8; + *dst = (r2 << 24) | (g2 << 19) | (b2 << 13) | + (r1 << 8) | (g1 << 3) | (b1 >> 3); + } +} + +// TODO? +void rgb888_to_rgb565(void *dst, const void *src, int bytes) {} +void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} + +#endif // __ARM_NEON__ + +/* YUV stuff */ +static int yuv_ry[32], yuv_gy[32], yuv_by[32]; +static unsigned char yuv_u[32 * 2], yuv_v[32 * 2]; + +void bgr_to_uyvy_init(void) +{ + int i, v; + + /* init yuv converter: + y0 = (int)((0.299f * r0) + (0.587f * g0) + (0.114f * b0)); + y1 = (int)((0.299f * r1) + (0.587f * g1) + (0.114f * b1)); + u = (int)(8 * 0.565f * (b0 - y0)) + 128; + v = (int)(8 * 0.713f * (r0 - y0)) + 128; + */ + for (i = 0; i < 32; i++) { + yuv_ry[i] = (int)(0.299f * i * 65536.0f + 0.5f); + yuv_gy[i] = (int)(0.587f * i * 65536.0f + 0.5f); + yuv_by[i] = (int)(0.114f * i * 65536.0f + 0.5f); + } + for (i = -32; i < 32; i++) { + v = (int)(8 * 0.565f * i) + 128; + if (v < 0) + v = 0; + if (v > 255) + v = 255; + yuv_u[i + 32] = v; + v = (int)(8 * 0.713f * i) + 128; + if (v < 0) + v = 0; + if (v > 255) + v = 255; + yuv_v[i + 32] = v; + } +} + +void rgb565_to_uyvy(void *d, const void *s, int pixels) +{ + unsigned int *dst = d; + const unsigned short *src = s; + const unsigned char *yu = yuv_u + 32; + const unsigned char *yv = yuv_v + 32; + int r0, g0, b0, r1, g1, b1; + int y0, y1, u, v; + + for (; pixels > 0; src += 2, dst++, pixels -= 2) + { + r0 = (src[0] >> 11) & 0x1f; + g0 = (src[0] >> 6) & 0x1f; + b0 = src[0] & 0x1f; + r1 = (src[1] >> 11) & 0x1f; + g1 = (src[1] >> 6) & 0x1f; + b1 = src[1] & 0x1f; + y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; + y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; + u = yu[b0 - y0]; + v = yv[r0 - y0]; + // valid Y range seems to be 16..235 + y0 = 16 + 219 * y0 / 31; + y1 = 16 + 219 * y1 / 31; + + *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; + } +} + +void bgr555_to_uyvy(void *d, const void *s, int pixels) +{ + unsigned int *dst = d; + const unsigned short *src = s; + const unsigned char *yu = yuv_u + 32; + const unsigned char *yv = yuv_v + 32; + int r0, g0, b0, r1, g1, b1; + int y0, y1, u, v; + + for (; pixels > 0; src += 2, dst++, pixels -= 2) + { + b0 = (src[0] >> 10) & 0x1f; + g0 = (src[0] >> 5) & 0x1f; + r0 = src[0] & 0x1f; + b1 = (src[1] >> 10) & 0x1f; + g1 = (src[1] >> 5) & 0x1f; + r1 = src[1] & 0x1f; + y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; + y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; + u = yu[b0 - y0]; + v = yv[r0 - y0]; + y0 = 16 + 219 * y0 / 31; + y1 = 16 + 219 * y1 / 31; + + *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; + } +} + +void bgr888_to_uyvy(void *d, const void *s, int pixels) +{ + unsigned int *dst = d; + const unsigned char *src8 = s; + const unsigned char *yu = yuv_u + 32; + const unsigned char *yv = yuv_v + 32; + int r0, g0, b0, r1, g1, b1; + int y0, y1, u, v; + + for (; pixels > 0; src8 += 3*2, dst++, pixels -= 2) + { + r0 = src8[0], g0 = src8[1], b0 = src8[2]; + r1 = src8[3], g1 = src8[4], b1 = src8[5]; + y0 = (r0 * 19595 + g0 * 38470 + b0 * 7471) >> 16; + y1 = (r1 * 19595 + g1 * 38470 + b1 * 7471) >> 16; + u = yu[(b0 - y0) / 8]; + v = yv[(r0 - y0) / 8]; + y0 = 16 + 219 * y0 / 255; + y1 = 16 + 219 * y1 / 255; + + *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; + } +} diff --git a/frontend/cspace.h b/frontend/cspace.h new file mode 100644 index 0000000..1a9e339 --- /dev/null +++ b/frontend/cspace.h @@ -0,0 +1,18 @@ +#ifdef __cplusplus +extern "C" +{ +#endif + +void bgr555_to_rgb565(void *dst, const void *src, int bytes); +void bgr888_to_rgb888(void *dst, const void *src, int bytes); +void bgr888_to_rgb565(void *dst, const void *src, int bytes); +void rgb888_to_rgb565(void *dst, const void *src, int bytes); + +void bgr_to_uyvy_init(void); +void rgb565_to_uyvy(void *d, const void *s, int pixels); +void bgr555_to_uyvy(void *d, const void *s, int pixels); +void bgr888_to_uyvy(void *d, const void *s, int pixels); + +#ifdef __cplusplus +} +#endif diff --git a/frontend/cspace_arm.S b/frontend/cspace_arm.S new file mode 100644 index 0000000..e9d15a5 --- /dev/null +++ b/frontend/cspace_arm.S @@ -0,0 +1,65 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2013 + * + * This work is licensed under the terms of GNU GPL version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "arm_features.h" + +.text +.align 2 + +@ lr=0x001f001f +@ trashes r11, r12 +.macro bgr555_to_rgb565_one rn + and r11, lr, \rn + and r12, lr, \rn, lsr #5 + and \rn, lr, \rn, lsr #10 + orr r12, r11, lsl #5 + orr \rn, r12, lsl #6 +.endm + +.macro pld_ reg offs=#0 +#ifdef HAVE_ARMV6 + pld [\reg, \offs] +#endif +.endm + +.global bgr555_to_rgb565 @ void *dst, const void *src, int bytes +bgr555_to_rgb565: + pld_ r1 + push {r4-r11,lr} + mov lr, #0x001f + subs r2, #4*8 + orr lr, lr, lsl #16 + blt 1f + +0: + ldmia r1!, {r3-r10} + subs r2, #4*8 + bgr555_to_rgb565_one r3 + + pld_ r1, #32*2 + bgr555_to_rgb565_one r4 + bgr555_to_rgb565_one r5 + bgr555_to_rgb565_one r6 + bgr555_to_rgb565_one r7 + bgr555_to_rgb565_one r8 + bgr555_to_rgb565_one r9 + bgr555_to_rgb565_one r10 + stmia r0!, {r3-r10} + bge 0b + +1: + adds r2, #4*8 + popeq {r4-r11,pc} + +2: + ldr r3, [r1], #4 + subs r2, #4 + bgr555_to_rgb565_one r3 + str r3, [r0], #4 + bgt 2b + + pop {r4-r11,pc} diff --git a/frontend/cspace_neon.s b/frontend/cspace_neon.s new file mode 100644 index 0000000..b458f06 --- /dev/null +++ b/frontend/cspace_neon.s @@ -0,0 +1,165 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2010 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * See the COPYING file in the top-level directory. + */ + +.text +.align 2 + +.global bgr555_to_rgb565 +bgr555_to_rgb565: + pld [r1] + mov r3, #0x07c0 + vdup.16 q15, r3 + subs r2, r2, #64 + blt btr16_end64 +0: + pld [r1, #64*2] + vldmia r1!, {q0-q3} + vshl.u16 q4, q0, #11 + vshl.u16 q5, q1, #11 + vshl.u16 q6, q2, #11 + vshl.u16 q7, q3, #11 + vsri.u16 q4, q0, #10 + vsri.u16 q5, q1, #10 + vsri.u16 q6, q2, #10 + vsri.u16 q7, q3, #10 + vshl.u16 q0, q0, #1 + vshl.u16 q1, q1, #1 + vshl.u16 q2, q2, #1 + vshl.u16 q3, q3, #1 + vbit q4, q0, q15 + vbit q5, q1, q15 + vbit q6, q2, q15 + vbit q7, q3, q15 + vstmia r0!, {q4-q7} + subs r2, r2, #64 + bge 0b + +btr16_end64: + adds r2, r2, #64 + bxeq lr + subs r2, r2, #16 + blt btr16_end16 + + @ handle the remainder (reasonably rare) +0: + vld1.16 {q0}, [r1]! + vshl.u16 q1, q0, #11 + vshl.u16 q2, q0, #1 + vsri.u16 q1, q0, #10 + vbit q1, q2, q15 + subs r2, r2, #16 + vst1.16 {q1}, [r0]! + bge 0b + +btr16_end16: + adds r2, r2, #16 + bxeq lr + subs r2, r2, #8 + bxlt lr + + @ very rare + vld1.16 d0, [r1]! + vshl.u16 d1, d0, #11 + vshl.u16 d2, d0, #1 + vsri.u16 d1, d0, #10 + vbit d1, d2, d30 + vst1.16 d1, [r0]! + bx lr + + +.global bgr888_to_rgb888 +bgr888_to_rgb888: + pld [r1] + @ r2 /= 48 + mov r2, r2, lsr #4 + movw r3, #0x5556 + movt r3, #0x5555 + umull r12,r2, r3, r2 +0: + pld [r1, #48*3] + vld3.8 {d0-d2}, [r1, :64]! + vld3.8 {d3-d5}, [r1, :64]! + vswp d0, d2 + vswp d3, d5 + vst3.8 {d0-d2}, [r0, :64]! + vst3.8 {d3-d5}, [r0, :64]! + subs r2, r2, #1 + bne 0b + + bx lr + + +.global bgr888_to_rgb565 +bgr888_to_rgb565: + pld [r1] + @ r2 /= 48 + mov r2, r2, lsr #4 + movw r3, #0x5556 + movt r3, #0x5555 + umull r12,r2, r3, r2 + + mov r3, #0x07e0 + vdup.16 q15, r3 +0: + pld [r1, #48*3] + vld3.8 {d1-d3}, [r1, :64]! + vld3.8 {d5-d7}, [r1, :64]! + + vshll.u8 q8, d2, #3 @ g + vshll.u8 q9, d6, #3 + vshr.u8 d0, d3, #3 @ b + vshr.u8 d4, d7, #3 + vzip.8 d0, d1 @ rb + vzip.8 d4, d5 + vbit q0, q8, q15 + vbit q2, q9, q15 + + vstmia r0!, {d0,d1} + vstmia r0!, {d4,d5} + subs r2, r2, #1 + bne 0b + + bx lr + + +.global rgb888_to_rgb565 +rgb888_to_rgb565: + pld [r1] + @ r2 /= 48 + mov r2, r2, lsr #4 + movw r3, #0x5556 + movt r3, #0x5555 + umull r12,r2, r3, r2 + + mov r3, #0x07e0 + vdup.16 q15, r3 +0: + pld [r1, #48*3] + vld3.8 {d1-d3}, [r1, :64]! + vld3.8 {d5-d7}, [r1, :64]! + + vshll.u8 q8, d2, #3 @ g + vshll.u8 q9, d6, #3 + vshr.u8 d2, d1, #3 @ b + vshr.u8 d6, d5, #3 + vzip.8 d2, d3 @ rb + vzip.8 d6, d7 + vbit q1, q8, q15 + vbit q3, q9, q15 + + vstmia r0!, {d2,d3} + vstmia r0!, {d6,d7} + subs r2, r2, #1 + bne 0b + + bx lr + + +@ vim:filetype=armasm diff --git a/frontend/libpicofe b/frontend/libpicofe -Subproject 215e7ed2510e191664b611a578ffb987cf4fdab +Subproject cceadf4cd4f1fa7e7f12b3765bba31bfcef6b1e diff --git a/frontend/libretro.c b/frontend/libretro.c index 4f6879e..c6d113f 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -15,7 +15,7 @@ #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../libpcsxcore/cheat.h" #include "../plugins/dfsound/out.h" -#include "../plugins/gpulib/cspace.h" +#include "cspace.h" #include "main.h" #include "plugin.h" #include "plugin_lib.h" diff --git a/frontend/main.c b/frontend/main.c index 0f0e641..df2af8f 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -50,7 +50,7 @@ extern int iUseInterpolation; extern int iXAPitch; extern int iVolume; -int ready_to_go, g_resetting; +int ready_to_go, g_emu_want_quit, g_emu_resetting; unsigned long gpuDisp; char cfgfile_basename[MAXPATHLEN]; int state_slot; @@ -437,6 +437,12 @@ int emu_core_init(void) return 0; } +void emu_core_ask_exit(void) +{ + stop = 1; + g_emu_want_quit = 1; +} + #ifndef NO_FRONTEND static void create_profile_dir(const char *directory) { char path[MAXPATHLEN]; @@ -622,7 +628,7 @@ int main(int argc, char *argv[]) pl_start_watchdog(); - while (1) + while (!g_emu_want_quit) { stop = 0; emu_action = SACTION_NONE; @@ -632,6 +638,12 @@ int main(int argc, char *argv[]) do_emu_action(); } + printf("Exit..\n"); + ClosePlugins(); + SysClose(); + menu_finish(); + plat_finish(); + return 0; } @@ -684,7 +696,7 @@ void SysReset() { // so we need to prevent updateLace() call.. void *real_lace = GPU_updateLace; GPU_updateLace = dummy_lace; - g_resetting = 1; + g_emu_resetting = 1; // reset can run code, timing must be set pl_timing_prepare(Config.PsxType); @@ -695,7 +707,7 @@ void SysReset() { CDR_stop(); GPU_updateLace = real_lace; - g_resetting = 0; + g_emu_resetting = 0; } void SysClose() { @@ -704,22 +716,15 @@ void SysClose() { StopDebugger(); - if (emuLog != NULL) fclose(emuLog); + if (emuLog != NULL && emuLog != stdout && emuLog != stderr) { + fclose(emuLog); + emuLog = NULL; + } } void SysUpdate() { } -void OnFile_Exit() { - printf("OnFile_Exit\n"); - SysClose(); -#ifndef NO_FRONTEND - menu_finish(); - plat_finish(); - exit(0); -#endif -} - int get_state_filename(char *buf, int size, int i) { return get_gameid_filename(buf, size, "." STATES_DIR "%.32s-%.9s.%3.3d", i); @@ -809,8 +814,7 @@ void SysMessage(const char *fmt, ...) { } static void SignalExit(int sig) { - ClosePlugins(); - OnFile_Exit(); + emu_core_ask_exit(); } #define PARSEPATH(dst, src) \ diff --git a/frontend/main.h b/frontend/main.h index d971890..7ce9e5d 100644 --- a/frontend/main.h +++ b/frontend/main.h @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA */ -#ifndef __LINUX_H__ -#define __LINUX_H__ +#ifndef __FRONTEND_MAIN_H__ +#define __FRONTEND_MAIN_H__ #include "config.h" @@ -41,6 +41,8 @@ extern int state_slot; int emu_core_preinit(void); int emu_core_init(void); +void emu_core_ask_exit(void); + void emu_set_default_config(void); void emu_on_new_cd(int show_hud_msg); @@ -52,7 +54,7 @@ int emu_load_state(int slot); void set_cd_image(const char *fname); extern unsigned long gpuDisp; -extern int ready_to_go, g_resetting; +extern int ready_to_go, g_emu_want_quit, g_emu_resetting; extern char hud_msg[64]; extern int hud_new_msg; @@ -68,7 +70,7 @@ enum sched_action { SACTION_SWITCH_DISPMODE, SACTION_FAST_FORWARD, SACTION_SCREENSHOT, - SACTION_VOLUME_UP, + SACTION_VOLUME_UP, // 10 SACTION_VOLUME_DOWN, SACTION_MINIMIZE, SACTION_TOGGLE_FPS, @@ -93,4 +95,4 @@ static inline void emu_set_action(enum sched_action action_) emu_action = action_; } -#endif /* __LINUX_H__ */ +#endif /* __FRONTEND_MAIN_H__ */ diff --git a/frontend/menu.c b/frontend/menu.c index 8119505..46e4298 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -26,6 +26,7 @@ #include "plugin_lib.h" #include "plat.h" #include "pcnt.h" +#include "cspace.h" #include "libpicofe/plat.h" #include "libpicofe/input.h" #include "libpicofe/linux/in_evdev.h" @@ -36,7 +37,6 @@ #include "../libpcsxcore/cheat.h" #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../plugins/dfinput/externals.h" -#include "../plugins/gpulib/cspace.h" #include "psemu_plugin_defs.h" #include "revision.h" @@ -1832,7 +1832,6 @@ static void menu_bios_warn(void) // ------------ main menu ------------ static menu_entry e_menu_main[]; -void OnFile_Exit(); static void draw_frame_main(void) { @@ -2153,8 +2152,8 @@ static int main_menu_handler(int id, int keys) in_menu_wait(PBTN_MOK|PBTN_MBACK, NULL, 70); break; case MA_MAIN_EXIT: - OnFile_Exit(); - break; + emu_core_ask_exit(); + return 1; default: lprintf("%s: something unknown selected\n", __FUNCTION__); break; @@ -2240,7 +2239,7 @@ void menu_loop(void) do { me_loop_d(e_menu_main, &sel, NULL, draw_frame_main); - } while (!ready_to_go); + } while (!ready_to_go && !g_emu_want_quit); /* wait until menu, ok, back is released */ while (in_menu_wait_any(NULL, 50) & (PBTN_MENU|PBTN_MOK|PBTN_MBACK)) diff --git a/frontend/plat_pollux.c b/frontend/plat_pollux.c index c932261..252feba 100644 --- a/frontend/plat_pollux.c +++ b/frontend/plat_pollux.c @@ -46,8 +46,8 @@ #include "main.h" #include "menu.h" #include "plat.h" +#include "cspace.h" #include "../libpcsxcore/psxmem_map.h" -#include "../plugins/gpulib/cspace.h" static int fbdev = -1; diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index 5b85375..dacf584 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -1,5 +1,5 @@ /* - * (C) Gražvydas "notaz" Ignotas, 2011,2012 + * (C) Gražvydas "notaz" Ignotas, 2011-2013 * * This work is licensed under the terms of any of these licenses * (at your option): @@ -17,8 +17,9 @@ #include "libpicofe/fonts.h" #include "libpicofe/plat_sdl.h" #include "libpicofe/gl.h" -#include "../plugins/gpulib/cspace.h" +#include "cspace.h" #include "plugin_lib.h" +#include "plugin.h" #include "main.h" #include "plat.h" #include "revision.h" @@ -56,7 +57,7 @@ static int psx_w, psx_h; static void *shadow_fb, *menubg_img; static int in_menu; -static int change_video_mode(void) +static int change_video_mode(int force) { int w, h; @@ -69,13 +70,39 @@ static int change_video_mode(void) h = psx_h; } - return plat_sdl_change_video_mode(w, h, 0); + return plat_sdl_change_video_mode(w, h, force); +} + +static void resize_cb(int w, int h) +{ + // used by some plugins.. + pl_rearmed_cbs.screen_w = w; + pl_rearmed_cbs.screen_h = h; + pl_rearmed_cbs.gles_display = gl_es_display; + pl_rearmed_cbs.gles_surface = gl_es_surface; + plugin_call_rearmed_cbs(); +} + +static void quit_cb(void) +{ + emu_core_ask_exit(); +} + +static void get_layer_pos(int *x, int *y, int *w, int *h) +{ + // always fill entire SDL window + *x = *y = 0; + *w = pl_rearmed_cbs.screen_w; + *h = pl_rearmed_cbs.screen_h; } void plat_init(void) { int ret; + plat_sdl_quit_cb = quit_cb; + plat_sdl_resize_cb = resize_cb; + ret = plat_sdl_init(); if (ret != 0) exit(1); @@ -93,6 +120,7 @@ void plat_init(void) in_sdl_init(in_sdl_defbinds, plat_sdl_event_handler); in_probe(); pl_rearmed_cbs.only_16bpp = 1; + pl_rearmed_cbs.pl_get_layer_pos = get_layer_pos; bgr_to_uyvy_init(); } @@ -162,7 +190,7 @@ void *plat_gvideo_set_mode(int *w, int *h, int *bpp) { psx_w = *w; psx_h = *h; - change_video_mode(); + change_video_mode(0); if (plat_sdl_overlay != NULL) { pl_plat_clear = plat_sdl_overlay_clear; pl_plat_blit = overlay_blit; @@ -204,6 +232,8 @@ void plat_gvideo_close(void) void plat_video_menu_enter(int is_rom_loaded) { + int force_mode_change = 0; + in_menu = 1; /* surface will be lost, must adjust pl_vout_buf for menu bg */ @@ -215,7 +245,11 @@ void plat_video_menu_enter(int is_rom_loaded) memcpy(menubg_img, plat_sdl_screen->pixels, psx_w * psx_h * 2); pl_vout_buf = menubg_img; - change_video_mode(); + /* gles plugin messes stuff up.. */ + if (pl_rearmed_cbs.gpu_caps & GPU_CAP_OWNS_DISPLAY) + force_mode_change = 1; + + change_video_mode(force_mode_change); } void plat_video_menu_begin(void) diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index dfff868..a3dcbab 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -28,10 +28,10 @@ #include "plat.h" #include "pcnt.h" #include "pl_gun_ts.h" +#include "cspace.h" #include "psemu_plugin_defs.h" #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../libpcsxcore/psxmem_map.h" -#include "../plugins/gpulib/cspace.h" #include "../plugins/dfinput/externals.h" int in_type1, in_type2; @@ -240,9 +240,12 @@ static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp) psx_w = raw_w; psx_h = raw_h; + psx_bpp = bpp; vout_w = w; vout_h = h; - vout_bpp = psx_bpp = bpp; + vout_bpp = bpp; + if (pl_rearmed_cbs.only_16bpp) + vout_bpp = 16; // don't use very low heights if (vout_h < 192) { @@ -270,7 +273,7 @@ static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp) pl_vout_buf = plat_gvideo_set_mode(&vout_w, &vout_h, &vout_bpp); if (pl_vout_buf == NULL && pl_plat_blit == NULL) fprintf(stderr, "failed to set mode %dx%d@%d\n", - vout_w, vout_h, psx_bpp); + vout_w, vout_h, vout_bpp); else { pl_vout_w = vout_w; pl_vout_h = vout_h; @@ -606,7 +609,7 @@ void pl_frame_limit(void) struct timeval now; int diff, usadj; - if (g_resetting) + if (g_emu_resetting) return; vsync_cnt++; diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index a83d954..4a11002 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -51,13 +51,15 @@ struct rearmed_cbs { // some stats, for display by some plugins int flips_per_sec, cpu_usage; float vsps_cur; // currect vsync/s + // these are for gles plugin + unsigned int screen_w, screen_h; + void *gles_display, *gles_surface; // gpu options int frameskip; int fskip_advice; unsigned int *gpu_frame_count; unsigned int *gpu_hcnt; unsigned int flip_cnt; // increment manually if not using pl_vout_flip - unsigned int screen_w, screen_h; // gles plugin wants this unsigned int only_16bpp; // platform is 16bpp-only struct { int allow_interlace; // 0 off, 1 on, 2 guess |