From 5deceb35bad09705603bba29243abdabc232b8a5 Mon Sep 17 00:00:00 2001 From: Sergi Granell Date: Sun, 30 Aug 2015 22:48:19 +0200 Subject: [PATCH] (Vita) Update Vita frontend --- frontend/drivers/platform_vita.c | 8 ++--- gfx/drivers/vita2d_gfx.c | 61 +++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/frontend/drivers/platform_vita.c b/frontend/drivers/platform_vita.c index 74422bab27..46a3b3e3e7 100644 --- a/frontend/drivers/platform_vita.c +++ b/frontend/drivers/platform_vita.c @@ -32,7 +32,7 @@ PSP2_MODULE_INFO(0, 0, "RetroArch"); -char eboot_path[512]; +char retroarch_path[512]; static bool exit_spawn = false; static bool exitspawn_start_game = false; @@ -54,9 +54,9 @@ static void frontend_vita_get_environment_settings(int *argc, char *argv[], #endif #endif - strlcpy(eboot_path, argv[0], sizeof(eboot_path)); + strlcpy(retroarch_path, "cache0:/retroarch/", sizeof(retroarch_path)); - fill_pathname_basedir(g_defaults.dir.port, argv[0], sizeof(g_defaults.dir.port)); + fill_pathname_basedir(g_defaults.dir.port, retroarch_path, sizeof(g_defaults.dir.port)); RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port); fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port, @@ -151,7 +151,7 @@ static void frontend_vita_exec(const char *path, bool should_load_game) SceSize args = 0; argp[0] = '\0'; - strlcpy(argp, eboot_path, sizeof(argp)); + strlcpy(argp, retroarch_path, sizeof(argp)); args = strlen(argp) + 1; #ifndef IS_SALAMANDER diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 80aed61ea1..793c24d460 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -19,6 +19,24 @@ #include +#define SCREEN_W 960 +#define SCREEN_H 544 + +typedef struct vita_video +{ + vita2d_texture *texture; + + bool vsync; + bool rgb32; + + video_viewport_t vp; + + unsigned rotation; + bool vblank_not_reached; + bool keep_aspect; + bool should_resize; +} vita_video_t; + static void *vita2d_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data) { @@ -26,26 +44,52 @@ static void *vita2d_gfx_init(const video_info_t *video, *input_data = NULL; (void)video; + vita_video_t *vita = (vita_video_t *)calloc(1, sizeof(vita_video_t)); + + if (!vita) + return NULL; + vita2d_init(); vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF)); + vita2d_set_vblank_wait(video->vsync); - return (void*)-1; + vita->texture = vita2d_create_empty_texture(SCREEN_W, SCREEN_H); + + vita->vsync = video->vsync; + vita->rgb32 = video->rgb32; + + return vita; } static bool vita2d_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg) { - (void)data; + vita_video_t *vita = (vita_video_t *)data; (void)frame; (void)width; (void)height; (void)pitch; (void)msg; + unsigned int *tex_p = vita2d_texture_get_datap(vita->texture); + unsigned int tex_stride = vita2d_texture_get_stride(vita->texture); + const unsigned int *frame_p = frame; + vita2d_start_drawing(); vita2d_clear_screen(); + int i, j; + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + tex_p[i + j * tex_stride] = frame_p[i + j * pitch]; + } + } + + vita2d_draw_texture(vita->texture, 0, 0); + vita2d_end_drawing(); vita2d_swap_buffers(); @@ -54,8 +98,13 @@ static bool vita2d_gfx_frame(void *data, const void *frame, static void vita2d_gfx_set_nonblock_state(void *data, bool toggle) { - (void)data; - (void)toggle; + vita_video_t *vita = (vita_video_t *)data; + + if (vita) + { + vita->vsync = !toggle; + vita2d_set_vblank_wait(vita->vsync); + } } static bool vita2d_gfx_alive(void *data) @@ -85,7 +134,9 @@ static bool vita2d_gfx_has_windowed(void *data) static void vita2d_gfx_free(void *data) { - (void)data; + vita_video_t *vita = (vita_video_t *)data; + + vita2d_free_texture(vita->texture); vita2d_fini(); }