generic ui, add basic GLES support

This commit is contained in:
kub 2022-06-19 22:46:50 +02:00
parent 7c6f79147b
commit 23e4719638
7 changed files with 54 additions and 26 deletions

View file

@ -159,11 +159,14 @@ OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
OBJS += platform/common/plat_sdl.o platform/common/input_sdlkbd.o OBJS += platform/common/plat_sdl.o platform/common/input_sdlkbd.o
OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
OBJS += platform/libpicofe/plat_dummy.o platform/libpicofe/linux/plat.o OBJS += platform/libpicofe/plat_dummy.o platform/libpicofe/linux/plat.o
OBJS += platform/libpicofe/gl.o
OBJS += platform/libpicofe/gl_platform.o
USE_FRONTEND = 1 USE_FRONTEND = 1
endif endif
ifeq "$(PLATFORM)" "generic" ifeq "$(PLATFORM)" "generic"
#ifeq (y,$(shell echo "\#include <GLES/gl.h>" | $(CC) -E -xc - >/dev/null 2>&1 && echo y))
ifeq "$(HAVE_GLES)" "1"
CFLAGS += -DHAVE_GLES -DSDL_REDRAW_EVT
LDFLAGS += -lEGL -lGLESv1_CM
endif
CFLAGS += -DSDL_OVERLAY_2X -DSDL_BUFFER_3X CFLAGS += -DSDL_OVERLAY_2X -DSDL_BUFFER_3X
OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
ifeq "$(use_inputmap)" "1" ifeq "$(use_inputmap)" "1"
@ -254,6 +257,9 @@ OBJS += platform/common/main.o platform/common/emu.o platform/common/upscale.o \
# libpicofe # libpicofe
OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \ OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \
platform/libpicofe/fonts.o platform/libpicofe/fonts.o
ifneq (,$(filter %HAVE_GLES, $(CFLAGS)))
OBJS += platform/libpicofe/gl.o platform/libpicofe/gl_platform.o
endif
# libpicofe - sound # libpicofe - sound
OBJS += platform/libpicofe/sndout.o OBJS += platform/libpicofe/sndout.o

9
configure vendored
View file

@ -50,6 +50,7 @@ have_arm_oabi=""
have_arm_neon="" have_arm_neon=""
have_libavcodec="" have_libavcodec=""
have_libchdr="" have_libchdr=""
have_gles="no"
need_sdl="no" need_sdl="no"
need_zlib="no" need_zlib="no"
@ -74,9 +75,11 @@ set_platform()
case "$platform" in case "$platform" in
rpi1) rpi1)
MFLAGS="mcpu=arm1176jzf-s -mfpu=vfp" MFLAGS="mcpu=arm1176jzf-s -mfpu=vfp"
have_gles="yes"
;; ;;
rpi2) rpi2)
MFLAGS="mcpu=cortex-a7 -mfpu=neon" MFLAGS="mcpu=cortex-a7 -mfpu=neon"
have_gles="yes"
;; ;;
generic) generic)
;; ;;
@ -155,6 +158,8 @@ for opt do
;; ;;
--with-libavcodec=*) have_libavcodec="$optarg" --with-libavcodec=*) have_libavcodec="$optarg"
;; ;;
--with-sdl-gles=*) have_gles="$optarg"
;;
*) echo "ERROR: unknown option $opt"; show_help="yes" *) echo "ERROR: unknown option $opt"; show_help="yes"
;; ;;
esac esac
@ -168,6 +173,7 @@ if [ "$show_help" = "yes" ]; then
echo " --sound-drivers=LIST sound output drivers [guessed]" echo " --sound-drivers=LIST sound output drivers [guessed]"
echo " available: $sound_driver_list" echo " available: $sound_driver_list"
echo " --with-libavcodec=yes|no use libavcodec for mp3 decoding" echo " --with-libavcodec=yes|no use libavcodec for mp3 decoding"
echo " --with-sdl-gles=yes|no enable GLES usage for SDL"
echo "influential environment variables:" echo "influential environment variables:"
echo " CROSS_COMPILE CC CXX AS STRIP CFLAGS ASFLAGS LDFLAGS LDLIBS" echo " CROSS_COMPILE CC CXX AS STRIP CFLAGS ASFLAGS LDFLAGS LDLIBS"
exit 1 exit 1
@ -447,6 +453,9 @@ echo >> $config_mak
echo "ARCH = $ARCH" >> $config_mak echo "ARCH = $ARCH" >> $config_mak
echo "PLATFORM = $platform" >> $config_mak echo "PLATFORM = $platform" >> $config_mak
echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
if [ "$have_gles" = "yes" ]; then
echo "HAVE_GLES = 1" >> $config_mak
fi
if [ "$have_libavcodec" = "yes" ]; then if [ "$have_libavcodec" = "yes" ]; then
echo "HAVE_LIBAVCODEC = 1" >> $config_mak echo "HAVE_LIBAVCODEC = 1" >> $config_mak
fi fi

View file

@ -69,6 +69,7 @@ static unsigned short fname2color(const char *fname)
#include <platform/libpicofe/menu.c> #include <platform/libpicofe/menu.c>
static const char *men_dummy[] = { NULL }; static const char *men_dummy[] = { NULL };
static int menu_w, menu_h;
/* platform specific options and handlers */ /* platform specific options and handlers */
#if defined(__GP2X__) #if defined(__GP2X__)
@ -147,7 +148,17 @@ static void copy_bg(int dir)
static void menu_enter(int is_rom_loaded) static void menu_enter(int is_rom_loaded)
{ {
if (is_rom_loaded) plat_video_menu_enter(is_rom_loaded);
menu_w = menu_h = 0;
}
static void menu_draw_prep(void)
{
if (menu_w == g_menuscreen_w && menu_h == g_menuscreen_h)
return;
menu_w = g_menuscreen_w, menu_h = g_menuscreen_h;
if (PicoGameLoaded)
{ {
make_bg(0, 0); make_bg(0, 0);
} }
@ -159,12 +170,11 @@ static void menu_enter(int is_rom_loaded)
strcpy(buff + pos, "background.png"); strcpy(buff + pos, "background.png");
// should really only happen once, on startup.. // should really only happen once, on startup..
memset(g_menubg_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);
if (readpng(g_menubg_ptr, buff, READPNG_BG, if (readpng(g_menubg_ptr, buff, READPNG_BG,
g_menuscreen_w, g_menuscreen_h) < 0) g_menuscreen_w, g_menuscreen_h) < 0)
memset(g_menubg_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2); memset(g_menubg_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);
} }
plat_video_menu_enter(is_rom_loaded);
} }
static void draw_savestate_bg(int slot) static void draw_savestate_bg(int slot)
@ -436,7 +446,7 @@ static int menu_loop_keyconfig(int id, int keys)
static int sel = 0; static int sel = 0;
me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, PicoGameLoaded); me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, PicoGameLoaded);
me_loop(e_menu_keyconfig, &sel); me_loop_d(e_menu_keyconfig, &sel, menu_draw_prep, NULL);
PicoSetInputDevice(0, currentConfig.input_dev0); PicoSetInputDevice(0, currentConfig.input_dev0);
PicoSetInputDevice(1, currentConfig.input_dev1); PicoSetInputDevice(1, currentConfig.input_dev1);
@ -461,7 +471,7 @@ static int menu_loop_md_options(int id, int keys)
static int sel = 0; static int sel = 0;
me_enable(e_menu_md_options, MA_OPT_RENDERER, renderer_names[0] != NULL); me_enable(e_menu_md_options, MA_OPT_RENDERER, renderer_names[0] != NULL);
me_loop(e_menu_md_options, &sel); me_loop_d(e_menu_md_options, &sel, menu_draw_prep, NULL);
return 0; return 0;
} }
@ -489,7 +499,7 @@ static menu_entry e_menu_cd_options[] =
static int menu_loop_cd_options(int id, int keys) static int menu_loop_cd_options(int id, int keys)
{ {
static int sel = 0; static int sel = 0;
me_loop(e_menu_cd_options, &sel); me_loop_d(e_menu_cd_options, &sel, menu_draw_prep, NULL);
return 0; return 0;
} }
@ -548,7 +558,7 @@ static int menu_loop_32x_options(int id, int keys)
static int sel = 0; static int sel = 0;
me_enable(e_menu_32x_options, MA_32XOPT_RENDERER, renderer_names32x[0] != NULL); me_enable(e_menu_32x_options, MA_32XOPT_RENDERER, renderer_names32x[0] != NULL);
me_loop(e_menu_32x_options, &sel); me_loop_d(e_menu_32x_options, &sel, menu_draw_prep, NULL);
Pico32xSetClocks(currentConfig.msh2_khz * 1000, currentConfig.msh2_khz * 1000); Pico32xSetClocks(currentConfig.msh2_khz * 1000, currentConfig.msh2_khz * 1000);
@ -580,7 +590,7 @@ static int menu_loop_sms_options(int id, int keys)
{ {
static int sel = 0; static int sel = 0;
me_loop(e_menu_sms_options, &sel); me_loop_d(e_menu_sms_options, &sel, menu_draw_prep, NULL);
return 0; return 0;
} }
@ -612,7 +622,7 @@ static int menu_loop_adv_options(int id, int keys)
{ {
static int sel = 0; static int sel = 0;
me_loop(e_menu_adv_options, &sel); me_loop_d(e_menu_adv_options, &sel, menu_draw_prep, NULL);
PicoIn.overclockM68k = currentConfig.overclock_68k; // int vs short PicoIn.overclockM68k = currentConfig.overclock_68k; // int vs short
return 0; return 0;
@ -701,7 +711,7 @@ static int menu_loop_snd_options(int id, int keys)
if (PicoIn.sndRate > 52000 && PicoIn.sndRate < 54000) if (PicoIn.sndRate > 52000 && PicoIn.sndRate < 54000)
PicoIn.sndRate = 53000; PicoIn.sndRate = 53000;
me_loop(e_menu_snd_options, &sel); me_loop_d(e_menu_snd_options, &sel, menu_draw_prep, NULL);
return 0; return 0;
} }
@ -739,7 +749,7 @@ static int menu_loop_gfx_options(int id, int keys)
{ {
static int sel = 0; static int sel = 0;
me_loop(e_menu_gfx_options, &sel); me_loop_d(e_menu_gfx_options, &sel, menu_draw_prep, NULL);
return 0; return 0;
} }
@ -762,7 +772,7 @@ static int menu_loop_ui_options(int id, int keys)
{ {
static int sel = 0; static int sel = 0;
me_loop(e_menu_ui_options, &sel); me_loop_d(e_menu_ui_options, &sel, menu_draw_prep, NULL);
return 0; return 0;
} }
@ -916,7 +926,7 @@ static int menu_loop_options(int id, int keys)
me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, PicoGameLoaded); me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, PicoGameLoaded);
me_enable(e_menu_options, MA_OPT_LOADCFG, config_slot != config_slot_current); me_enable(e_menu_options, MA_OPT_LOADCFG, config_slot != config_slot_current);
me_loop(e_menu_options, &sel); me_loop_d(e_menu_options, &sel, menu_draw_prep, NULL);
return 0; return 0;
} }
@ -1265,7 +1275,7 @@ void menu_loop(void)
menu_enter(PicoGameLoaded); menu_enter(PicoGameLoaded);
in_set_config_int(0, IN_CFG_BLOCKING, 1); in_set_config_int(0, IN_CFG_BLOCKING, 1);
me_loop_d(e_menu_main, &sel, NULL, menu_main_draw_status); me_loop_d(e_menu_main, &sel, menu_draw_prep, menu_main_draw_status);
if (PicoGameLoaded) { if (PicoGameLoaded) {
if (engineState == PGS_Menu) if (engineState == PGS_Menu)
@ -1318,7 +1328,7 @@ int menu_loop_tray(void)
menu_enter(PicoGameLoaded); menu_enter(PicoGameLoaded);
in_set_config_int(0, IN_CFG_BLOCKING, 1); in_set_config_int(0, IN_CFG_BLOCKING, 1);
me_loop(e_menu_tray, &sel); me_loop_d(e_menu_tray, &sel, menu_draw_prep, NULL);
if (engineState != PGS_RestartRun) { if (engineState != PGS_RestartRun) {
engineState = PGS_RestartRun; engineState = PGS_RestartRun;

View file

@ -234,12 +234,11 @@ void plat_video_menu_enter(int is_rom_loaded)
{ {
if (SDL_MUSTLOCK(plat_sdl_screen)) if (SDL_MUSTLOCK(plat_sdl_screen))
SDL_UnlockSurface(plat_sdl_screen); SDL_UnlockSurface(plat_sdl_screen);
plat_sdl_change_video_mode(g_menuscreen_w, g_menuscreen_h, 1);
resize_buffers();
} }
void plat_video_menu_begin(void) void plat_video_menu_begin(void)
{ {
plat_sdl_change_video_mode(g_menuscreen_w, g_menuscreen_h, 1);
resize_buffers(); resize_buffers();
if (plat_sdl_overlay || plat_sdl_gl_active) { if (plat_sdl_overlay || plat_sdl_gl_active) {
g_menuscreen_pp = g_menuscreen_w; g_menuscreen_pp = g_menuscreen_w;
@ -318,10 +317,10 @@ void plat_early_init(void)
static void plat_sdl_resize(int w, int h) static void plat_sdl_resize(int w, int h)
{ {
// take over new settings // take over new settings
g_menuscreen_h = (plat_sdl_screen->h < 480 ? plat_sdl_screen->h : 480); g_menuscreen_h = plat_sdl_screen->h;
if (!plat_sdl_overlay && !plat_sdl_gl_active) g_menuscreen_w = plat_sdl_screen->w;
g_menuscreen_h = plat_sdl_screen->h; resize_buffers();
g_menuscreen_w = g_menuscreen_h * plat_sdl_screen->w/plat_sdl_screen->h; rendstatus_old = -1;
} }
static void plat_sdl_quit(void) static void plat_sdl_quit(void)

View file

@ -18,6 +18,7 @@ const char *men_scaling_opts[] = { "OFF", "software", "hardware", NULL };
static menu_entry e_menu_adv_options[]; static menu_entry e_menu_adv_options[];
static menu_entry e_menu_gfx_options[]; static menu_entry e_menu_gfx_options[];
static menu_entry e_menu_sms_options[];
static menu_entry e_menu_options[]; static menu_entry e_menu_options[];
static menu_entry e_menu_keyconfig[]; static menu_entry e_menu_keyconfig[];

@ -1 +1 @@
Subproject commit e3ea3015f042cb3a1615dc3038b524ce0a063722 Subproject commit f5b32cc30c98b1772cdfd4ed1ff5476dced770cc

View file

@ -303,7 +303,8 @@ void pemu_forced_frame(int no_scale, int do_emu)
emu_cmn_forced_frame(no_scale, do_emu, screen_buffer(g_screen_ptr)); emu_cmn_forced_frame(no_scale, do_emu, screen_buffer(g_screen_ptr));
render_bg = 0; render_bg = 0;
g_menubg_src_ptr = g_screen_ptr; g_menubg_src_ptr = realloc(g_menubg_src_ptr, g_screen_height * g_screen_ppitch * 2);
memcpy(g_menubg_src_ptr, g_screen_ptr, g_screen_height * g_screen_ppitch * 2);
currentConfig.scaling = hs, currentConfig.vscaling = vs; currentConfig.scaling = hs, currentConfig.vscaling = vs;
} }
@ -365,6 +366,7 @@ void emu_video_mode_change(int start_line, int line_count, int start_col, int co
out_y = start_line; out_x = start_col; out_y = start_line; out_x = start_col;
out_h = line_count; out_w = col_count; out_h = line_count; out_w = col_count;
plat_video_loop_prepare(); // recalculates g_screen_w/h
PicoDrawSetCallbacks(NULL, NULL); PicoDrawSetCallbacks(NULL, NULL);
// center output in screen // center output in screen
screen_w = g_screen_width, screen_x = (screen_w - out_w)/2; screen_w = g_screen_width, screen_x = (screen_w - out_w)/2;
@ -402,7 +404,6 @@ void emu_video_mode_change(int start_line, int line_count, int start_col, int co
} }
plat_video_set_size(screen_w, screen_h); plat_video_set_size(screen_w, screen_h);
plat_video_set_buffer(g_screen_ptr);
if (screen_w < g_screen_width) if (screen_w < g_screen_width)
screen_x = (g_screen_width - screen_w)/2; screen_x = (g_screen_width - screen_w)/2;
@ -413,6 +414,8 @@ void emu_video_mode_change(int start_line, int line_count, int start_col, int co
screen_y += (224 - out_h)/2; screen_y += (224 - out_h)/2;
} }
plat_video_set_buffer(g_screen_ptr);
// create a backing buffer for emulating the bad GG lcd display // create a backing buffer for emulating the bad GG lcd display
if (currentConfig.ghosting && out_h == 144) { if (currentConfig.ghosting && out_h == 144) {
int h = currentConfig.vscaling == EOPT_SCALE_SW ? 240:out_h; int h = currentConfig.vscaling == EOPT_SCALE_SW ? 240:out_h;