Merge pull request #3763 from jriwanek-forks/4.0.2-fix

Fixes and GHA for SDL UI
This commit is contained in:
Miran Grča
2023-10-17 16:56:52 +02:00
committed by GitHub
5 changed files with 91 additions and 23 deletions

View File

@@ -313,6 +313,9 @@ jobs:
new: on new: on
slug: -NDR slug: -NDR
ui: ui:
- name: SDL GUI
qt: off
static: on
- name: Qt GUI - name: Qt GUI
qt: on qt: on
slug: -Qt slug: -Qt
@@ -406,6 +409,11 @@ jobs:
new: on new: on
slug: -NDR slug: -NDR
ui: ui:
- name: SDL GUI
qt: off
static: on
src-packages: >-
libsndfile
- name: Qt GUI - name: Qt GUI
qt: on qt: on
slug: -Qt slug: -Qt

View File

@@ -26,6 +26,7 @@ on:
jobs: jobs:
analyze-msys2: analyze-msys2:
name: "Analyze Windows MSYS2 (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, ${{ matrix.environment.msystem }})" name: "Analyze Windows MSYS2 (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, ${{ matrix.environment.msystem }})"
runs-on: windows-2022 runs-on: windows-2022
@@ -171,6 +172,8 @@ jobs:
new: on new: on
slug: -NDR slug: -NDR
ui: ui:
- name: SDL GUI
qt: off
- name: Qt GUI - name: Qt GUI
qt: on qt: on
slug: -Qt slug: -Qt
@@ -224,6 +227,7 @@ jobs:
category: "/language:${{matrix.language}}" category: "/language:${{matrix.language}}"
analyze-macos11: analyze-macos11:
name: "Analyze macOS 11 (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64)" name: "Analyze macOS 11 (${{ matrix.ui.name }}, ${{ matrix.build.name }}, ${{ matrix.dynarec.name }}, x86_64)"
runs-on: macos-11 runs-on: macos-11
@@ -254,6 +258,8 @@ jobs:
new: on new: on
slug: -NDR slug: -NDR
ui: ui:
- name: SDL GUI
qt: off
- name: Qt GUI - name: Qt GUI
qt: on qt: on
slug: -Qt slug: -Qt

View File

@@ -197,7 +197,7 @@ if(NOT EMU_BUILD_NUM)
set(EMU_BUILD_NUM 0) set(EMU_BUILD_NUM 0)
endif() endif()
if(NOT EMU_COPYRIGHT_YEAR) if(NOT EMU_COPYRIGHT_YEAR)
set(EMU_COPYRIGHT_YEAR 2022) set(EMU_COPYRIGHT_YEAR 2023)
endif() endif()
add_subdirectory(src) add_subdirectory(src)

View File

@@ -21,6 +21,10 @@
#include <pwd.h> #include <pwd.h>
#include <stdatomic.h> #include <stdatomic.h>
#ifdef __APPLE__
# include "macOSXGlue.h"
#endif
#include <86box/86box.h> #include <86box/86box.h>
#include <86box/mem.h> #include <86box/mem.h>
#include <86box/rom.h> #include <86box/rom.h>
@@ -41,10 +45,6 @@
#include <86box/ui.h> #include <86box/ui.h>
#include <86box/gdbstub.h> #include <86box/gdbstub.h>
#ifdef __APPLE__
# include "macOSXGlue.h"
#endif
static int first_use = 1; static int first_use = 1;
static uint64_t StartingTime; static uint64_t StartingTime;
static uint64_t Frequency; static uint64_t Frequency;
@@ -191,6 +191,7 @@ dynld_module(const char *name, dllimp_t *table)
{ {
dllimp_t *imp; dllimp_t *imp;
void *modhandle = dlopen(name, RTLD_LAZY | RTLD_GLOBAL); void *modhandle = dlopen(name, RTLD_LAZY | RTLD_GLOBAL);
if (modhandle) { if (modhandle) {
for (imp = table; imp->name != NULL; imp++) { for (imp = table; imp->name != NULL; imp++) {
if ((*(void **) imp->func = dlsym(modhandle, imp->name)) == NULL) { if ((*(void **) imp->func = dlsym(modhandle, imp->name)) == NULL) {
@@ -199,6 +200,7 @@ dynld_module(const char *name, dllimp_t *table)
} }
} }
} }
return modhandle; return modhandle;
} }
@@ -405,7 +407,7 @@ plat_mmap(size_t size, uint8_t executable)
#if defined __APPLE__ && defined MAP_JIT #if defined __APPLE__ && defined MAP_JIT
void *ret = mmap(0, size, PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0), MAP_ANON | MAP_PRIVATE | (executable ? MAP_JIT : 0), -1, 0); void *ret = mmap(0, size, PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0), MAP_ANON | MAP_PRIVATE | (executable ? MAP_JIT : 0), -1, 0);
#else #else
void *ret = mmap(0, size, PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0), MAP_ANON | MAP_PRIVATE, -1, 0); void *ret = mmap(0, size, PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0), MAP_ANON | MAP_PRIVATE, -1, 0);
#endif #endif
return (ret < 0) ? NULL : ret; return (ret < 0) ? NULL : ret;
} }
@@ -427,6 +429,7 @@ plat_get_ticks_common(void)
{ {
uint64_t EndingTime; uint64_t EndingTime;
uint64_t ElapsedMicroseconds; uint64_t ElapsedMicroseconds;
if (first_use) { if (first_use) {
Frequency = SDL_GetPerformanceFrequency(); Frequency = SDL_GetPerformanceFrequency();
StartingTime = SDL_GetPerformanceCounter(); StartingTime = SDL_GetPerformanceCounter();
@@ -434,6 +437,7 @@ plat_get_ticks_common(void)
} }
EndingTime = SDL_GetPerformanceCounter(); EndingTime = SDL_GetPerformanceCounter();
ElapsedMicroseconds = ((EndingTime - StartingTime) * 1000000) / Frequency; ElapsedMicroseconds = ((EndingTime - StartingTime) * 1000000) / Frequency;
return ElapsedMicroseconds; return ElapsedMicroseconds;
} }
@@ -458,11 +462,13 @@ plat_remove(char *path)
void void
ui_sb_update_icon_state(int tag, int state) ui_sb_update_icon_state(int tag, int state)
{ {
/* No-op. */
} }
void void
ui_sb_update_icon(int tag, int active) ui_sb_update_icon(int tag, int active)
{ {
/* No-op. */
} }
void void
@@ -474,25 +480,26 @@ plat_delay_ms(uint32_t count)
void void
ui_sb_update_tip(int arg) ui_sb_update_tip(int arg)
{ {
/* No-op. */
} }
void void
ui_sb_update_panes(void) ui_sb_update_panes(void)
{ {
/* No-op. */
} }
void void
ui_sb_update_text(void) ui_sb_update_text(void)
{ {
/* No-op. */
} }
void void
path_get_dirname(char *dest, const char *path) path_get_dirname(char *dest, const char *path)
{ {
int c = (int) strlen(path); int c = (int) strlen(path);
char *ptr; char *ptr = (char *) path;
ptr = (char *) path;
while (c > 0) { while (c > 0) {
if (path[c] == '/' || path[c] == '\\') { if (path[c] == '/' || path[c] == '\\') {
@@ -511,6 +518,7 @@ volatile int cpu_thread_run = 1;
void void
ui_sb_set_text_w(wchar_t *wstr) ui_sb_set_text_w(wchar_t *wstr)
{ {
/* No-op. */
} }
int int
@@ -634,12 +642,16 @@ ui_msgbox_header(int flags, void *header, void *message)
{ {
SDL_MessageBoxData msgdata; SDL_MessageBoxData msgdata;
SDL_MessageBoxButtonData msgbtn; SDL_MessageBoxButtonData msgbtn;
#if 0
if (!header) if (!header)
header = (void *) (flags & MBX_ANSI) ? "86Box" : L"86Box"; header = (void *) (flags & MBX_ANSI) ? "86Box" : L"86Box";
#endif
if (header <= (void *) 7168) if (header <= (void *) 7168)
header = (void *) plat_get_string((int) header); header = (void *) plat_get_string((uintptr_t) header);
if (message <= (void *) 7168) if (message <= (void *) 7168)
message = (void *) plat_get_string((int) message); message = (void *) plat_get_string((uintptr_t) message);
msgbtn.buttonid = 1; msgbtn.buttonid = 1;
msgbtn.text = "OK"; msgbtn.text = "OK";
msgbtn.flags = 0; msgbtn.flags = 0;
@@ -679,6 +691,7 @@ void
plat_get_exe_name(char *s, int size) plat_get_exe_name(char *s, int size)
{ {
char *basepath = SDL_GetBasePath(); char *basepath = SDL_GetBasePath();
snprintf(s, size, "%s%s", basepath, basepath[strlen(basepath) - 1] == '/' ? "86box" : "/86box"); snprintf(s, size, "%s%s", basepath, basepath[strlen(basepath) - 1] == '/' ? "86box" : "/86box");
} }
@@ -699,6 +712,7 @@ plat_power_off(void)
void void
ui_sb_bugui(char *str) ui_sb_bugui(char *str)
{ {
/* No-op. */
} }
extern void sdl_blit(int x, int y, int w, int h); extern void sdl_blit(int x, int y, int w, int h);
@@ -709,13 +723,17 @@ typedef struct mouseinputdata {
int deltaz; int deltaz;
int mousebuttons; int mousebuttons;
} mouseinputdata; } mouseinputdata;
SDL_mutex *mousemutex;
int real_sdl_w; SDL_mutex *mousemutex;
int real_sdl_h; int real_sdl_w;
int real_sdl_h;
void void
ui_sb_set_ready(int ready) ui_sb_set_ready(int ready)
{ {
/* No-op. */
} }
char *xargv[512]; char *xargv[512];
// From musl. // From musl.
@@ -724,6 +742,7 @@ local_strsep(char **str, const char *sep)
{ {
char *s = *str; char *s = *str;
char *end; char *end;
if (!s) if (!s)
return NULL; return NULL;
end = s + strcspn(s, sep); end = s + strcspn(s, sep);
@@ -732,6 +751,7 @@ local_strsep(char **str, const char *sep)
else else
end = 0; end = 0;
*str = end; *str = end;
return s; return s;
} }
@@ -761,6 +781,7 @@ plat_init_rom_paths(void)
#ifndef __APPLE__ #ifndef __APPLE__
if (getenv("XDG_DATA_HOME")) { if (getenv("XDG_DATA_HOME")) {
char xdg_rom_path[1024] = { 0 }; char xdg_rom_path[1024] = { 0 };
strncpy(xdg_rom_path, getenv("XDG_DATA_HOME"), 1024); strncpy(xdg_rom_path, getenv("XDG_DATA_HOME"), 1024);
path_slash(xdg_rom_path); path_slash(xdg_rom_path);
strncat(xdg_rom_path, "86Box/", 1024); strncat(xdg_rom_path, "86Box/", 1024);
@@ -774,6 +795,7 @@ plat_init_rom_paths(void)
rom_add_path(xdg_rom_path); rom_add_path(xdg_rom_path);
} else { } else {
char home_rom_path[1024] = { 0 }; char home_rom_path[1024] = { 0 };
snprintf(home_rom_path, 1024, "%s/.local/share/86Box/", getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir); snprintf(home_rom_path, 1024, "%s/.local/share/86Box/", getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir);
if (!plat_dir_check(home_rom_path)) if (!plat_dir_check(home_rom_path))
@@ -788,6 +810,7 @@ plat_init_rom_paths(void)
char *xdg_rom_paths = strdup(getenv("XDG_DATA_DIRS")); char *xdg_rom_paths = strdup(getenv("XDG_DATA_DIRS"));
char *xdg_rom_paths_orig = xdg_rom_paths; char *xdg_rom_paths_orig = xdg_rom_paths;
char *cur_xdg_rom_path = NULL; char *cur_xdg_rom_path = NULL;
if (xdg_rom_paths) { if (xdg_rom_paths) {
while (xdg_rom_paths[strlen(xdg_rom_paths) - 1] == ':') { while (xdg_rom_paths[strlen(xdg_rom_paths) - 1] == ':') {
xdg_rom_paths[strlen(xdg_rom_paths) - 1] = '\0'; xdg_rom_paths[strlen(xdg_rom_paths) - 1] = '\0';
@@ -828,7 +851,9 @@ bool
process_media_commands_3(uint8_t *id, char *fn, uint8_t *wp, int cmdargc) process_media_commands_3(uint8_t *id, char *fn, uint8_t *wp, int cmdargc)
{ {
bool err = false; bool err = false;
*id = atoi(xargv[1]); *id = atoi(xargv[1]);
if (xargv[2][0] == '\'' || xargv[2][0] == '"') { if (xargv[2][0] == '\'' || xargv[2][0] == '"') {
for (int curarg = 2; curarg < cmdargc; curarg++) { for (int curarg = 2; curarg < cmdargc; curarg++) {
if (strlen(fn) + strlen(xargv[curarg]) >= PATH_MAX) { if (strlen(fn) + strlen(xargv[curarg]) >= PATH_MAX) {
@@ -868,6 +893,7 @@ void (*f_rl_callback_handler_remove)(void) = NULL;
#else #else
# define LIBEDIT_LIBRARY "libedit.so" # define LIBEDIT_LIBRARY "libedit.so"
#endif #endif
uint32_t uint32_t
timer_onesec(uint32_t interval, void *param) timer_onesec(uint32_t interval, void *param)
{ {
@@ -882,6 +908,7 @@ monitor_thread(void *param)
if (isatty(fileno(stdin)) && isatty(fileno(stdout))) { if (isatty(fileno(stdin)) && isatty(fileno(stdout))) {
char *line = NULL; char *line = NULL;
size_t n; size_t n;
printf("86Box monitor console.\n"); printf("86Box monitor console.\n");
while (!exit_event) { while (!exit_event) {
if (feof(stdin)) if (feof(stdin))
@@ -890,11 +917,12 @@ monitor_thread(void *param)
line = f_readline("(86Box) "); line = f_readline("(86Box) ");
else { else {
printf("(86Box) "); printf("(86Box) ");
getline(&line, &n, stdin); !getline(&line, &n, stdin);
} }
if (line) { if (line) {
int cmdargc = 0; int cmdargc = 0;
char *linecpy; char *linecpy;
line[strcspn(line, "\r\n")] = '\0'; line[strcspn(line, "\r\n")] = '\0';
linecpy = strdup(line); linecpy = strdup(line);
if (!linecpy) { if (!linecpy) {
@@ -989,6 +1017,7 @@ monitor_thread(void *param)
memset(fn, 0, sizeof(fn)); memset(fn, 0, sizeof(fn));
if (xargv[2][0] == '\'' || xargv[2][0] == '"') { if (xargv[2][0] == '\'' || xargv[2][0] == '"') {
int curarg = 2; int curarg = 2;
for (curarg = 2; curarg < cmdargc; curarg++) { for (curarg = 2; curarg < cmdargc; curarg++) {
if (strlen(fn) + strlen(xargv[curarg]) >= PATH_MAX) { if (strlen(fn) + strlen(xargv[curarg]) >= PATH_MAX) {
err = true; err = true;
@@ -1031,7 +1060,9 @@ monitor_thread(void *param)
uint8_t wp; uint8_t wp;
bool err = false; bool err = false;
char fn[PATH_MAX]; char fn[PATH_MAX];
memset(fn, 0, sizeof(fn)); memset(fn, 0, sizeof(fn));
if (!xargv[2] || !xargv[1]) { if (!xargv[2] || !xargv[1]) {
free(line); free(line);
free(linecpy); free(linecpy);
@@ -1051,7 +1082,9 @@ monitor_thread(void *param)
uint8_t wp; uint8_t wp;
bool err = false; bool err = false;
char fn[PATH_MAX]; char fn[PATH_MAX];
memset(fn, 0, sizeof(fn)); memset(fn, 0, sizeof(fn));
if (!xargv[2] || !xargv[1]) { if (!xargv[2] || !xargv[1]) {
free(line); free(line);
free(linecpy); free(linecpy);
@@ -1071,7 +1104,9 @@ monitor_thread(void *param)
uint8_t wp; uint8_t wp;
bool err = false; bool err = false;
char fn[PATH_MAX]; char fn[PATH_MAX];
memset(fn, 0, sizeof(fn)); memset(fn, 0, sizeof(fn));
if (!xargv[2] || !xargv[1]) { if (!xargv[2] || !xargv[1]) {
free(line); free(line);
free(linecpy); free(linecpy);
@@ -1091,7 +1126,9 @@ monitor_thread(void *param)
uint8_t wp; uint8_t wp;
bool err = false; bool err = false;
char fn[PATH_MAX]; char fn[PATH_MAX];
memset(fn, 0, sizeof(fn)); memset(fn, 0, sizeof(fn));
if (!xargv[2] || !xargv[1]) { if (!xargv[2] || !xargv[1]) {
free(line); free(line);
free(linecpy); free(linecpy);
@@ -1170,6 +1207,7 @@ main(int argc, char **argv)
SDL_AddTimer(1000, timer_onesec, NULL); SDL_AddTimer(1000, timer_onesec, NULL);
while (!is_quit) { while (!is_quit) {
static int mouse_inside = 0; static int mouse_inside = 0;
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
switch (event.type) { switch (event.type) {
case SDL_QUIT: case SDL_QUIT:
@@ -1244,6 +1282,7 @@ main(int argc, char **argv)
case SDL_RENDER_TARGETS_RESET: case SDL_RENDER_TARGETS_RESET:
{ {
extern void sdl_reinit_texture(void); extern void sdl_reinit_texture(void);
sdl_reinit_texture(); sdl_reinit_texture();
break; break;
} }
@@ -1251,6 +1290,7 @@ main(int argc, char **argv)
case SDL_KEYUP: case SDL_KEYUP:
{ {
uint16_t xtkey = 0; uint16_t xtkey = 0;
switch (event.key.keysym.scancode) { switch (event.key.keysym.scancode) {
default: default:
xtkey = sdl_to_xt[event.key.keysym.scancode]; xtkey = sdl_to_xt[event.key.keysym.scancode];
@@ -1326,6 +1366,7 @@ plat_language_code(char *langcode)
void void
plat_get_cpu_string(char *outbuf, uint8_t len) { plat_get_cpu_string(char *outbuf, uint8_t len) {
char cpu_string[] = "Unknown"; char cpu_string[] = "Unknown";
strncpy(outbuf, cpu_string, len); strncpy(outbuf, cpu_string, len);
} }
@@ -1340,15 +1381,21 @@ plat_language_code_r(uint32_t lcid, char *outbuf, int len)
void void
joystick_init(void) joystick_init(void)
{ {
/* No-op. */
} }
void void
joystick_close(void) joystick_close(void)
{ {
/* No-op. */
} }
void void
joystick_process(void) joystick_process(void)
{ {
/* No-op. */
} }
void void
startblit(void) startblit(void)
{ {
@@ -1365,9 +1412,11 @@ endblit(void)
void void
ui_sb_mt32lcd(char *str) ui_sb_mt32lcd(char *str)
{ {
/* No-op. */
} }
void void
ui_hard_reset_completed(void) ui_hard_reset_completed(void)
{ {
/* No-op. */
} }

View File

@@ -51,7 +51,7 @@ int title_set = 0;
int resize_pending = 0; int resize_pending = 0;
int resize_w = 0; int resize_w = 0;
int resize_h = 0; int resize_h = 0;
static uint8_t interpixels[17842176]; static void *pixeldata;
extern void RenderImGui(void); extern void RenderImGui(void);
static void static void
@@ -150,11 +150,15 @@ sdl_blit_shim(int x, int y, int w, int h, int monitor_index)
params.y = y; params.y = y;
params.w = w; params.w = w;
params.h = h; params.h = h;
if (!(!sdl_enabled || (x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) || (monitor_index >= 1)) if (!(!sdl_enabled || (x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) || (monitor_index >= 1))
video_copy(interpixels, &(buffer32->line[y][x]), h * 2048 * sizeof(uint32_t)); for (int row = 0; row < h; ++row)
if (screenshots) video_copy(&(((uint8_t *) pixeldata)[row * 2048 * sizeof(uint32_t)]), &(buffer32->line[y + row][x]), w * sizeof(uint32_t));
video_screenshot(interpixels, 0, 0, 2048);
if (monitors[monitor_index].mon_screenshots)
video_screenshot((uint32_t *) pixeldata, 0, 0, 2048);
blitreq = 1; blitreq = 1;
video_blit_complete_monitor(monitor_index); video_blit_complete_monitor(monitor_index);
} }
@@ -167,6 +171,7 @@ sdl_real_blit(SDL_Rect *r_src)
int ret; int ret;
int winx; int winx;
int winy; int winy;
SDL_GL_GetDrawableSize(sdl_win, &winx, &winy); SDL_GL_GetDrawableSize(sdl_win, &winx, &winy);
SDL_RenderClear(sdl_render); SDL_RenderClear(sdl_render);
@@ -213,7 +218,7 @@ sdl_blit(int x, int y, int w, int h)
r_src.y = y; r_src.y = y;
r_src.w = w; r_src.w = w;
r_src.h = h; r_src.h = h;
SDL_UpdateTexture(sdl_tex, &r_src, interpixels, 2048 * 4); SDL_UpdateTexture(sdl_tex, &r_src, pixeldata, 2048 * 4);
blitreq = 0; blitreq = 0;
sdl_real_blit(&r_src); sdl_real_blit(&r_src);
@@ -270,8 +275,6 @@ sdl_close(void)
sdl_flags = -1; sdl_flags = -1;
} }
static int old_capture = 0;
void void
sdl_enable(int enable) sdl_enable(int enable)
{ {
@@ -392,7 +395,6 @@ plat_vidapi(char *api)
static int static int
sdl_init_common(int flags) sdl_init_common(int flags)
{ {
wchar_t temp[128];
SDL_version ver; SDL_version ver;
/* Get and log the version of the DLL we are using. */ /* Get and log the version of the DLL we are using. */
@@ -526,10 +528,13 @@ ui_window_title(wchar_t *str)
void void
ui_init_monitor(int monitor_index) ui_init_monitor(int monitor_index)
{ {
/* No-op. */
} }
void void
ui_deinit_monitor(int monitor_index) ui_deinit_monitor(int monitor_index)
{ {
/* No-op. */
} }
void void