From fbac0d5692c5343dd163ba289f80d167dd8582c7 Mon Sep 17 00:00:00 2001 From: neonloop Date: Sun, 14 Mar 2021 00:03:40 +0000 Subject: Initial trimui s support --- Makefile | 37 +++++ configure | 21 ++- frontend/main.c | 2 +- frontend/menu.c | 5 +- frontend/menu_trimui.h | 31 +++++ frontend/plat_trimui.c | 361 +++++++++++++++++++++++++++++++++++++++++++++++++ frontend/plugin.c | 6 +- 7 files changed, 454 insertions(+), 9 deletions(-) create mode 100644 frontend/menu_trimui.h create mode 100644 frontend/plat_trimui.c diff --git a/Makefile b/Makefile index 73bde48..8df42cf 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ # default stuff goes here, so that config can override TARGET ?= pcsx CFLAGS += -Wall -Iinclude -ffast-math + ifeq ($(DEBUG), 1) CFLAGS += -O0 -ggdb else @@ -15,6 +16,7 @@ endif CXXFLAGS += $(CFLAGS) #DRC_DBG = 1 #PCNT = 1 +PICO_HOME_DIR=".pcsx" all: config.mak target_ plugins_ @@ -44,6 +46,16 @@ ifdef PCNT CFLAGS += -DPCNT endif +ifeq ($(PROFILE), YES) +CFLAGS += -fprofile-generate=./profile +else ifeq ($(PROFILE), APPLY) +CFLAGS += -fprofile-use -fprofile-dir=./profile -fbranch-probabilities +endif + +ifeq ($(PROFILE), YES) +LDFLAGS += -lgcov +endif + # core OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \ libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \ @@ -312,6 +324,20 @@ frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_gp2x.h USE_PLUGIN_LIB = 1 USE_FRONTEND = 1 endif +ifeq "$(PLATFORM)" "trimui" +SYSROOT := $(shell $(CC) --print-sysroot) +SDL_CFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags) +SDL_LDFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --libs) +OBJS += frontend/libpicofe/in_sdl.o +OBJS += frontend/libpicofe/linux/in_evdev.o +OBJS += frontend/plat_trimui.o frontend/blit320.o +frontend/main.o frontend/menu.o: CFLAGS += -include frontend/menu_trimui.h +USE_PLUGIN_LIB = 1 +USE_FRONTEND = 1 +CFLAGS += -DGPULIB_USE_MMAP -DGPU_UNAI_USE_INT_DIV_MULTINV -fomit-frame-pointer -ffast-math -ffunction-sections -fsingle-precision-constant +CFLAGS += $(SDL_CFLAGS) -DTRIMUI +LDFLAGS += $(SDL_LDFLAGS) -flto -fwhole-program +endif ifeq "$(PLATFORM)" "maemo" OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o maemo/%.o: maemo/%.c @@ -471,3 +497,14 @@ rel: pcsx $(PLUGINS) \ mkdir out/pcsx_rearmed/bios/ cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip * endif +ifeq "$(PLATFORM)" "trimui" +VER = v1.9 +rel: pcsx $(PLUGINS) \ + readme.txt COPYING + rm -rf out + mkdir -p out/pcsx_rearmed/ + cp -r $^ out/pcsx_rearmed/ + mkdir out/pcsx_rearmed/lib/ + mkdir out/pcsx_rearmed/bios/ + cd out && zip -9 -r ../pcsx_rearmed_$(VER)_trimui.zip * +endif diff --git a/configure b/configure index f3a50d1..67aefad 100755 --- a/configure +++ b/configure @@ -37,7 +37,7 @@ check_define_val() # setting options to "yes" or "no" will make that choice default, # "" means "autodetect". -platform_list="generic pandora maemo caanoo libretro" +platform_list="generic pandora maemo caanoo libretro trimui" platform="generic" builtin_gpu_list="peops unai neon" builtin_gpu="" @@ -107,6 +107,18 @@ set_platform() optimize_arm926ej="yes" need_warm="yes" ;; + trimui) + ARCH="arm" + sound_drivers="sdl" + have_tslib="no" + have_chd="yes" + ram_fixed="yes" + drc_cache_base="no" # usually works, sometimes not + optimize_arm926ej="yes" + need_warm="no" + have_arm_neon="no" + plugins="" + ;; libretro) sound_drivers="libretro" need_libpicofe="no" @@ -569,7 +581,7 @@ if [ "$have_gles" = "yes" ]; then echo "LDLIBS_GLES = $LDLIBS_GLES" >> $config_mak fi if [ "$enable_dynarec" = "yes" ]; then - echo "USE_DYNAREC = 1" >> $config_mak + echo "DYNAREC = ari64" >> $config_mak fi if [ "$drc_cache_base" = "yes" ]; then echo "DRC_CACHE_BASE = 1" >> $config_mak @@ -577,8 +589,11 @@ fi if [ "$have_c64x_dsp" = "yes" ]; then echo "HAVE_C64_TOOLS = 1" >> $config_mak fi +if [ "$have_chd" = "yes" ]; then + echo "HAVE_CHD = 1" >> $config_mak +fi # use pandora's skin (for now) -test -e skin || ln -s frontend/pandora/skin skin +# test -e skin || ln -s frontend/pandora/skin skin # vim:shiftwidth=2:expandtab diff --git a/frontend/main.c b/frontend/main.c index d3c7d40..cf45475 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -133,7 +133,7 @@ void emu_set_default_config(void) pl_rearmed_cbs.gpu_peops.iUseDither = 0; pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7; pl_rearmed_cbs.gpu_unai.ilace_force = 0; - pl_rearmed_cbs.gpu_unai.pixel_skip = 1; + pl_rearmed_cbs.gpu_unai.pixel_skip = 0; pl_rearmed_cbs.gpu_unai.lighting = 1; pl_rearmed_cbs.gpu_unai.fast_lighting = 1; pl_rearmed_cbs.gpu_unai.blending = 1; diff --git a/frontend/menu.c b/frontend/menu.c index bd56cf4..9fa5fd2 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -123,6 +123,7 @@ static int bios_sel, gpu_plugsel, spu_plugsel; #define MENU_SHOW_MINIMIZE 0 #define MENU_SHOW_FULLSCREEN 1 #define MENU_SHOW_VOLUME 0 +#define MENU_SHOW_DISPLAY 1 #endif static int min(int x, int y) { return x < y ? x : y; } @@ -2515,9 +2516,6 @@ void menu_init(void) exit(1); } - emu_make_path(buff, "skin/background.png", sizeof(buff)); - readpng(g_menubg_src_ptr, buff, READPNG_BG, g_menuscreen_w, g_menuscreen_h); - i = plat_target.cpu_clock_set != NULL && plat_target.cpu_clock_get != NULL && cpu_clock_st > 0; me_enable(e_menu_gfx_options, MA_OPT_CPU_CLOCKS, i); @@ -2545,6 +2543,7 @@ void menu_init(void) me_enable(e_menu_keyconfig, MA_CTRL_NUBS_BTNS, MENU_SHOW_NUBS_BTNS); me_enable(e_menu_keyconfig, MA_CTRL_VIBRATION, MENU_SHOW_VIBRATION); me_enable(e_menu_keyconfig, MA_CTRL_DEADZONE, MENU_SHOW_DEADZONE); + me_enable(e_menu_options, MA_OPT_DISP_OPTS, MENU_SHOW_DISPLAY); } void menu_notify_mode_change(int w, int h, int bpp) diff --git a/frontend/menu_trimui.h b/frontend/menu_trimui.h new file mode 100644 index 0000000..6fa0fdc --- /dev/null +++ b/frontend/menu_trimui.h @@ -0,0 +1,31 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef UI_FEATURES_H +#define UI_FEATURES_H + +#define MENU_BIOS_PATH "pcsx_rearmed/bios/" +#define MENU_SHOW_VARSCALER 0 +#define MENU_SHOW_VOUTMODE 0 +#define MENU_SHOW_SCALER2 0 +#define MENU_SHOW_NUBS_BTNS 0 +#define MENU_SHOW_VIBRATION 0 +#define MENU_SHOW_DEADZONE 0 +#define MENU_SHOW_MINIMIZE 0 +#define MENU_SHOW_FULLSCREEN 1 +#define MENU_SHOW_VOLUME 0 +#define MENU_SHOW_DISPLAY 0 + +#endif diff --git a/frontend/plat_trimui.c b/frontend/plat_trimui.c new file mode 100644 index 0000000..5b99d97 --- /dev/null +++ b/frontend/plat_trimui.c @@ -0,0 +1,361 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include +#include + +#include "main.h" +#include "menu.h" +#include "plat.h" +#include "cspace.h" +#include "blit320.h" +#include "plugin_lib.h" +#include "libpicofe/menu.h" +#include "libpicofe/plat.h" +#include "libpicofe/input.h" +#include "libpicofe/in_sdl.h" +#include "../libpcsxcore/psxmem_map.h" + +SDL_Surface* screen; +struct plat_target plat_target; + +static unsigned short *psx_vram; +static unsigned short *cspace_buf; +static int psx_step, psx_width, psx_height, psx_bpp; +static int psx_offset_x, psx_offset_y, psx_src_width, psx_src_height; +static int fb_offset_x, fb_offset_y; + +static const struct in_default_bind in_sdl_defbinds[] = { + { SDLK_UP, IN_BINDTYPE_PLAYER12, DKEY_UP }, + { SDLK_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN }, + { SDLK_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT }, + { SDLK_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT }, + { SDLK_LSHIFT, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE }, + { SDLK_LCTRL, IN_BINDTYPE_PLAYER12, DKEY_CROSS }, + { SDLK_SPACE, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE }, + { SDLK_LALT, IN_BINDTYPE_PLAYER12, DKEY_SQUARE }, + { SDLK_RETURN, IN_BINDTYPE_PLAYER12, DKEY_START }, + { SDLK_RCTRL, IN_BINDTYPE_PLAYER12, DKEY_SELECT }, + { SDLK_TAB, IN_BINDTYPE_PLAYER12, DKEY_L1 }, + { SDLK_BACKSPACE, IN_BINDTYPE_PLAYER12, DKEY_R1 }, + { SDLK_e, IN_BINDTYPE_PLAYER12, DKEY_L2 }, + { SDLK_t, IN_BINDTYPE_PLAYER12, DKEY_R2 }, + { SDLK_ESCAPE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU }, + { SDLK_F1, IN_BINDTYPE_EMU, SACTION_SAVE_STATE }, + { SDLK_F2, IN_BINDTYPE_EMU, SACTION_LOAD_STATE }, + { SDLK_F3, IN_BINDTYPE_EMU, SACTION_PREV_SSLOT }, + { SDLK_F4, IN_BINDTYPE_EMU, SACTION_NEXT_SSLOT }, + { SDLK_F5, IN_BINDTYPE_EMU, SACTION_TOGGLE_FSKIP }, + { SDLK_F6, IN_BINDTYPE_EMU, SACTION_SCREENSHOT }, + { SDLK_F7, IN_BINDTYPE_EMU, SACTION_TOGGLE_FPS }, + { SDLK_F8, IN_BINDTYPE_EMU, SACTION_SWITCH_DISPMODE }, + { SDLK_F11, IN_BINDTYPE_EMU, SACTION_TOGGLE_FULLSCREEN }, + { SDLK_F12, IN_BINDTYPE_EMU, SACTION_FAST_FORWARD }, + { 0, 0, 0 } +}; + +const struct menu_keymap in_sdl_key_map[] = +{ + { SDLK_UP, PBTN_UP }, + { SDLK_DOWN, PBTN_DOWN }, + { SDLK_LEFT, PBTN_LEFT }, + { SDLK_RIGHT, PBTN_RIGHT }, + { SDLK_SPACE, PBTN_MOK }, + { SDLK_LCTRL, PBTN_MBACK }, + { SDLK_LALT, PBTN_MA2 }, + { SDLK_LSHIFT, PBTN_MA3 }, + { SDLK_TAB, PBTN_L }, + { SDLK_BACKSPACE, PBTN_R }, +}; + +const struct menu_keymap in_sdl_joy_map[] = +{ + { SDLK_UP, PBTN_UP }, + { SDLK_DOWN, PBTN_DOWN }, + { SDLK_LEFT, PBTN_LEFT }, + { SDLK_RIGHT, PBTN_RIGHT }, + { SDLK_WORLD_0, PBTN_MOK }, + { SDLK_WORLD_1, PBTN_MBACK }, + { SDLK_WORLD_2, PBTN_MA2 }, + { SDLK_WORLD_3, PBTN_MA3 }, +}; + +static const struct in_pdata in_sdl_platform_data = { + .defbinds = in_sdl_defbinds, + .key_map = in_sdl_key_map, + .kmap_size = sizeof(in_sdl_key_map) / sizeof(in_sdl_key_map[0]), + .joy_map = in_sdl_joy_map, + .jmap_size = sizeof(in_sdl_joy_map) / sizeof(in_sdl_joy_map[0]), +}; + +static void *fb_flip(void) +{ + static int flip=0; + + { + flip^=1; + SDL_Flip(screen); + } + return screen->pixels; +} + +void plat_video_menu_enter(int is_rom_loaded) +{ +} + +void plat_video_menu_begin(void) +{ + g_menuscreen_ptr = fb_flip(); +} + +void plat_video_menu_end(void) +{ + g_menuscreen_ptr = fb_flip(); +} + +void plat_video_menu_leave(void) +{ + if (psx_vram == NULL) { + printf("%s, GPU plugin did not provide vram\n", __func__); + exit(-1); + } + + SDL_LockSurface(screen); + memset(g_menuscreen_ptr, 0, 320*240 * sizeof(uint16_t)); + SDL_UnlockSurface(screen); + g_menuscreen_ptr = fb_flip(); + SDL_LockSurface(screen); + memset(g_menuscreen_ptr, 0, 320*240 * sizeof(uint16_t)); + SDL_UnlockSurface(screen); +} + +void *plat_prepare_screenshot(int *w, int *h, int *bpp) +{ + *w = 320; + *h = 240; + *bpp = psx_bpp; + return pl_vout_buf; +} + +void plat_minimize(void) +{ +} + +#define make_flip_func(name, blitfunc) \ +static void name(int doffs, const void *vram_, int w, int h, int sstride, int bgr24) \ +{ \ + const unsigned short *vram = vram_; \ + unsigned char *conv = (unsigned char *)cspace_buf; \ + unsigned char *dst = (unsigned char *)screen->pixels + \ + (fb_offset_y * 320 + fb_offset_x) * sizeof(uint16_t); \ + int dst_stride = 640; \ + int len = psx_src_width * psx_bpp / 8; \ + int i; \ + void (*convertfunc)(void *dst, const void *src, int bytes); \ + convertfunc = psx_bpp == 24 ? bgr888_to_rgb565 : bgr555_to_rgb565; \ + \ + SDL_LockSurface(screen); \ + vram += psx_offset_y * 1024 + psx_offset_x; \ + for (i = psx_src_height; i > 0; i--, \ + vram += psx_step * 1024, \ + dst += dst_stride, \ + conv += dst_stride) { \ + convertfunc(conv, vram, len); \ + blitfunc(dst, conv, dst_stride); \ + } \ + SDL_UnlockSurface(screen); \ +} + +make_flip_func(raw_blit_soft, memcpy) +make_flip_func(raw_blit_soft_368, blit320_368) +make_flip_func(raw_blit_soft_512, blit320_512) +make_flip_func(raw_blit_soft_640, blit320_640) + +void *plat_gvideo_set_mode(int *w_, int *h_, int *bpp_) +{ + int poff_w, poff_h, w_max; + int w = *w_, h = *h_, bpp = *bpp_; + + if (!w || !h || !bpp) + return NULL; + + printf("psx mode: %dx%d@%d\n", w, h, bpp); + psx_width = w; + psx_height = h; + psx_bpp = bpp; + + switch (w + (bpp != 16) + !soft_scaling) { + case 640: + pl_plat_blit = raw_blit_soft_640; + w_max = 640; + break; + case 512: + pl_plat_blit = raw_blit_soft_512; + w_max = 512; + break; + case 384: + case 368: + pl_plat_blit = raw_blit_soft_368; + w_max = 368; + break; + default: + pl_plat_blit = raw_blit_soft; + w_max = 320; + break; + } + + psx_step = 1; + if (h > 256) { + psx_step = 2; + h /= 2; + } + + poff_w = poff_h = 0; + if (w > w_max) { + poff_w = w / 2 - w_max / 2; + w = w_max; + } + fb_offset_x = 0; + if (w < 320) + fb_offset_x = 320/2 - w / 2; + if (h > 240) { + poff_h = h / 2 - 240/2; + h = 240; + } + fb_offset_y = 240/2 - h / 2; + + psx_offset_x = poff_w * psx_bpp/8 / 2; + psx_offset_y = poff_h; + psx_src_width = w; + psx_src_height = h; + + if (fb_offset_x || fb_offset_y) { + // not fullscreen, must clear borders + SDL_LockSurface(screen); + memset(g_menuscreen_ptr, 0, 320*240 * sizeof(uint16_t)); + SDL_UnlockSurface(screen); + g_menuscreen_ptr = fb_flip(); + SDL_LockSurface(screen); + memset(g_menuscreen_ptr, 0, 320*240 * sizeof(uint16_t)); + SDL_UnlockSurface(screen); + memset(cspace_buf, 0, 320*240 * sizeof(uint16_t)); + } + + // adjust for hud + *w_ = 320; + *h_ = fb_offset_y + psx_src_height; + return g_menuscreen_ptr; +} + +/* not really used, we do raw_flip */ +void plat_gvideo_open(int is_pal) +{ +} + +void *plat_gvideo_flip(void) +{ + g_menuscreen_ptr = fb_flip(); + return g_menuscreen_ptr; +} + +void plat_gvideo_close(void) +{ +} + +static void *pl_emu_mmap(unsigned long addr, size_t size, int is_fixed, enum psxMapTag tag) +{ + void *retval; + + retval = plat_mmap(addr, size, 0, is_fixed); + if (tag == MAP_TAG_VRAM) { + psx_vram = retval; + } + return retval; +} + +static void pl_emu_munmap(void *ptr, size_t size, enum psxMapTag tag) +{ + plat_munmap(ptr, size); +} + +void plat_sdl_event_handler(void *event_) +{ +} + +void plat_init(void) +{ + int ret; + + if (SDL_WasInit(SDL_INIT_EVERYTHING)) { + SDL_InitSubSystem(SDL_INIT_VIDEO); + } + else { + SDL_Init(SDL_INIT_VIDEO); + } + screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE); + if (screen == NULL) { + printf("%s, failed to set video mode\n", __func__); + exit(-1); + } + SDL_ShowCursor(0); + system("echo 10 > /proc/sys/vm/swappiness"); + + cspace_buf = calloc(1, 640 * 480 * sizeof(uint16_t)); + if (!cspace_buf) { + printf("%s, failed to allocate color conversion buffer\n", __func__); + exit(-1); + } + + g_menuscreen_w = 320; + g_menuscreen_h = 240; + g_menuscreen_ptr = fb_flip(); + + in_sdl_init(&in_sdl_platform_data, plat_sdl_event_handler); + in_probe(); + + pl_plat_blit = raw_blit_soft; + psx_src_width = 320; + psx_src_height = 240; + psx_bpp = 16; + + pl_rearmed_cbs.screen_w = 320; + pl_rearmed_cbs.screen_h = 240; + psxMapHook = pl_emu_mmap; + psxUnmapHook = pl_emu_munmap; + in_enable_vibration = 1; +} + +void plat_pre_finish(void) +{ + system("echo 60 > /proc/sys/vm/swappiness"); +} + +void plat_finish(void) +{ + if (cspace_buf) { + free(cspace_buf); + } + + SDL_Quit(); +} + +void plat_trigger_vibrate(int pad, int low, int high) +{ +} diff --git a/frontend/plugin.c b/frontend/plugin.c index a617c24..47578d3 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -70,13 +70,13 @@ static long PADreadPort1(PadDataS *pad) { pad->absoluteX = in_analog_left[pad_index][0]; pad->absoluteY = in_analog_left[pad_index][1]; } - +#ifdef HAVE_LIBRETRO if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE) { pad->moveX = in_mouse[pad_index][0]; pad->moveY = in_mouse[pad_index][1]; } - +#endif return 0; } @@ -102,11 +102,13 @@ static long PADreadPort2(PadDataS *pad) { pad->absoluteY = in_analog_left[pad_index][1]; } +#ifdef HAVE_LIBRETRO if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE) { pad->moveX = in_mouse[pad_index][0]; pad->moveY = in_mouse[pad_index][1]; } +#endif return 0; } -- cgit v1.2.3