picodrive icon indicating copy to clipboard operation
picodrive copied to clipboard

Scale for generic sdl build?

Open tokumeiwokiboushimasu opened this issue 7 years ago • 4 comments

I want to use this emulator with 2x scale. Is it possible? If not, can you add the option please?

tokumeiwokiboushimasu avatar Jan 12 '18 15:01 tokumeiwokiboushimasu

I was wondering about 2x scaling on Ubuntu 18.04 x86-64. Best I could come up with was a patch to build the opengl output which normally scales that way.

Not being a programmer, I constructed the LDFLAGS based on various stackexchange questions regarding how to build GL/GLES. Using this patch is something like:

git apply picogl.patch
patch -p1 < picogl.patch
diff --git a/Makefile b/Makefile
index 2903a68..956cadc 100644
--- a/Makefile
+++ b/Makefile
@@ -86,10 +86,14 @@ OBJS += platform/libpicofe/gl_platform.o
 USE_FRONTEND = 1
 endif
 ifeq "$(PLATFORM)" "generic"
+CFLAGS += -DHAVE_GLES
+LDFLAGS += -ldl -lpthread -lGL -lGLU -lglut -lEGL -lGLESv2
 OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
 OBJS += platform/common/plat_sdl.o
 OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
 OBJS += platform/libpicofe/plat_dummy.o
+OBJS += platform/libpicofe/gl.o
+OBJS += platform/libpicofe/gl_platform.o
 USE_FRONTEND = 1
 endif
 ifeq "$(PLATFORM)" "pandora"
diff --git a/platform/libpicofe/gl.c b/platform/libpicofe/gl.c
--- a/platform/libpicofe/gl.c	2018-07-07 20:00:32.282290503 -0600
+++ b/platform/libpicofe/gl.c	2018-07-07 19:52:54.322950774 -0600
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 
 #include <EGL/egl.h>
-#include <GLES/gl.h>
+#include <GL/gl.h>
 #include "gl_platform.h"
 #include "gl.h"
 
diff --git a/platform/libpicofe/gl_platform.c b/platform/libpicofe/gl_platform.c
--- a/platform/libpicofe/gl_platform.c	2018-07-07 20:00:32.282290503 -0600
+++ b/platform/libpicofe/gl_platform.c	2018-07-07 19:52:45.643114431 -0600
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <EGL/egl.h>
-#include <GLES/gl.h>
+#include <GL/gl.h>
 
 #include "gl.h"
 #include "gl_platform.h"

Includes would be like: libglu1-mesa-dev libgles2-mesa-dev libglew-dev freeglut3-dev

noabody avatar Jul 10 '18 15:07 noabody

Is freeglut strictly needed? I managed to compile using your patch on one of my systems that didn't had freeglut3-dev installed by just leaving -lglut out.

dilworks avatar Feb 26 '19 22:02 dilworks

Oh, I haven't used that for awhile I guess. You can view my current patch at Picodrive patch.

The relevant part is is limited and extends joystick functionality to the d-pad. The full patch also makes picodrive system install possible on debian with checkinstall:

diff --git a/Makefile b/Makefile
index 2903a68..a06c5b4 100644
--- a/Makefile
+++ b/Makefile
@@ -86,10 +86,14 @@ OBJS += platform/libpicofe/gl_platform.o
 USE_FRONTEND = 1
 endif
 ifeq "$(PLATFORM)" "generic"
+CFLAGS += -DHAVE_GLES
+LDFLAGS += -ldl -lpthread -lGL -lEGL
 OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
 OBJS += platform/common/plat_sdl.o
 OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
 OBJS += platform/libpicofe/plat_dummy.o
+OBJS += platform/libpicofe/gl.o
+OBJS += platform/libpicofe/gl_platform.o
 USE_FRONTEND = 1
 endif
 ifeq "$(PLATFORM)" "pandora"
diff --git a/platform/libpicofe/gl.c b/platform/libpicofe/gl.c
--- a/platform/libpicofe/gl.c	2018-07-07 20:00:32.282290503 -0600
+++ b/platform/libpicofe/gl.c	2018-07-07 19:52:54.322950774 -0600
@@ -2,7 +2,11 @@
 #include <stdlib.h>
 
 #include <EGL/egl.h>
-#include <GLES/gl.h>
+#if defined(__arm__)
+  #include <GLES/gl.h>
+#else
+  #include <GL/gl.h>
+#endif
 #include "gl_platform.h"
 #include "gl.h"
 
diff --git a/platform/libpicofe/gl_platform.c b/platform/libpicofe/gl_platform.c
--- a/platform/libpicofe/gl_platform.c	2018-07-07 20:00:32.282290503 -0600
+++ b/platform/libpicofe/gl_platform.c	2018-07-07 19:52:45.643114431 -0600
@@ -1,7 +1,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <EGL/egl.h>
-#include <GLES/gl.h>
+#if defined(__arm__)
+  #include <GLES/gl.h>
+#else
+  #include <GL/gl.h>
+#endif
 
 #include "gl.h"
 #include "gl_platform.h"

diff --git a/platform/libpicofe/in_sdl.c  b/platform/libpicofe/in_sdl.c
--- a/platform/libpicofe/in_sdl.c	2018-07-29 08:38:02.016564259 -0600
+++ b/platform/libpicofe/in_sdl.c	2018-07-29 08:37:06.309806921 -0600
@@ -300,6 +300,34 @@
 		}
 		break;
 
+	case SDL_JOYHATMOTION:
+		if (event->jhat.which != state->joy_id)
+			return -2;
+		if (event->jhat.value == SDL_HAT_CENTERED) {
+			kc = state->axis_keydown[event->jhat.hat];
+			state->axis_keydown[event->jhat.hat] = 0;
+			ret = 1;
+		}
+		else if (event->jhat.value & SDL_HAT_UP || event->jhat.value & SDL_HAT_LEFT) {
+			kc = state->axis_keydown[event->jhat.hat];
+			if (kc)
+				update_keystate(state->keystate, kc, 0);
+			kc = (event->jhat.value & SDL_HAT_UP) ? SDLK_UP : SDLK_LEFT;
+			state->axis_keydown[event->jhat.hat] = kc;
+			down = 1;
+			ret = 1;
+		}
+		else if (event->jhat.value & SDL_HAT_DOWN || event->jhat.value & SDL_HAT_RIGHT) {
+			kc = state->axis_keydown[event->jhat.hat];
+			if (kc)
+				update_keystate(state->keystate, kc, 0);
+			kc = (event->jhat.value & SDL_HAT_DOWN) ? SDLK_DOWN : SDLK_RIGHT;
+			state->axis_keydown[event->jhat.hat] = kc;
+			down = 1;
+			ret = 1;
+		}
+		break;
+
 	case SDL_JOYBUTTONDOWN:
 	case SDL_JOYBUTTONUP:
 		if (event->jbutton.which != state->joy_id)

noabody avatar Feb 27 '19 01:02 noabody

As a sort of patch while this isn't implemented, in Linux you can use xpra like the following:

xpra start --no-daemon --exit-with-children=True --attach=True --opengl=yes:gtk --desktop-scaling=200% --start-child=PicoDrive

where --desktop-scaling lets you set at which scale you want to run the emulator at.

xerz-one avatar Feb 01 '20 14:02 xerz-one