Merge branch 'master' of ssh://github.com/86Box/86Box into cleanup30

This commit is contained in:
RichardG867
2022-04-07 15:46:00 -03:00
22 changed files with 426 additions and 69 deletions

22
.ci/Jenkinsfile vendored
View File

@@ -24,12 +24,14 @@ def buildBranch = env.JOB_BASE_NAME.contains('-') ? 1 : 0
def osArchs = [ def osArchs = [
'Windows': ['32', '64'], 'Windows': ['32', '64'],
'Linux': ['x86', 'x86_64', 'arm32', 'arm64'] 'Linux': ['x86', 'x86_64', 'arm32', 'arm64'],
'macOS': ['x86_64']
] ]
def osFlags = [ def osFlags = [
'Windows': '-D QT=ON', 'Windows': '-D QT=ON',
'Linux': '-D QT=ON' 'Linux': '-D QT=ON',
'macOS': '-D QT=ON'
] ]
def archNames = [ def archNames = [
@@ -41,6 +43,11 @@ def archNames = [
'arm64': 'ARM (64-bit)' 'arm64': 'ARM (64-bit)'
] ]
def archNamesMac = [
'x86_64': 'Intel',
'arm64': 'Apple Silicon'
]
def dynarecNames = [ def dynarecNames = [
'ODR': 'Old Recompiler (recommended)', 'ODR': 'Old Recompiler (recommended)',
'NDR': 'New Recompiler (beta)', 'NDR': 'New Recompiler (beta)',
@@ -53,9 +60,7 @@ def dynarecArchs = [
'64': ['ODR', 'NDR'], '64': ['ODR', 'NDR'],
'x86_64': ['ODR', 'NDR'], 'x86_64': ['ODR', 'NDR'],
'arm32': ['NDR'], 'arm32': ['NDR'],
'ARM32': ['NDR'], 'arm64': ['NDR']
'arm64': ['NDR'],
'ARM64': ['NDR']
] ]
def dynarecFlags = [ def dynarecFlags = [
@@ -238,7 +243,7 @@ pipeline {
osArchs.each { os, thisOsArchs -> osArchs.each { os, thisOsArchs ->
def combinations = [:] def combinations = [:]
thisOsArchs.each { arch -> thisOsArchs.each { arch ->
def thisArchDynarecs = dynarecArchs[arch] def thisArchDynarecs = dynarecArchs[arch.toLowerCase()]
if (!thisArchDynarecs) if (!thisArchDynarecs)
thisArchDynarecs = ['NoDR'] thisArchDynarecs = ['NoDR']
thisArchDynarecs.each { dynarec -> thisArchDynarecs.each { dynarec ->
@@ -257,7 +262,10 @@ pipeline {
/* Run build process. */ /* Run build process. */
def packageName = "${env.JOB_BASE_NAME}${dynarecSlugs[dynarec]}${presetSlugs[preset]}-$os-$arch$buildSuffix" def packageName = "${env.JOB_BASE_NAME}${dynarecSlugs[dynarec]}${presetSlugs[preset]}-$os-$arch$buildSuffix"
def ret = -1 def ret = -1
dir("${dynarecNames[dynarec]}/$os - ${archNames[arch]}") { def archName = archNames[arch]
if (os == 'macOS')
archName = archNamesMac[arch]
dir("${dynarecNames[dynarec]}/$os - $archName") {
ret = runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} ${osFlags[os]} $buildFlags") ret = runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} ${osFlags[os]} $buildFlags")
} }

View File

@@ -28,9 +28,17 @@
# - Packaging the Discord DLL requires wget (MSYS should come with it) # - Packaging the Discord DLL requires wget (MSYS should come with it)
# - For Linux builds: # - For Linux builds:
# - Only Debian and derivatives are supported # - Only Debian and derivatives are supported
# - dpkg and apt-get are called through sudo to manage dependencies # - dpkg and apt-get are called through sudo to manage dependencies; make sure those
# are configured as NOPASSWD in /etc/sudoers if you're doing unattended builds
# - For macOS builds: # - For macOS builds:
# - TBD # - A standard MacPorts installation is required, with the following macports.conf settings:
# buildfromsource always
# build_arch x86_64 (or arm64)
# universal_archs (blank)
# ui_interactive no
# macosx_deployment_target 10.13
# - port is called through sudo to manage dependencies; make sure it is configured
# as NOPASSWD in /etc/sudoers if you're doing unattended builds
# #
# Define common functions. # Define common functions.
@@ -178,13 +186,16 @@ fi
echo [-] Building [$package_name] for [$arch] with flags [$cmake_flags] echo [-] Building [$package_name] for [$arch] with flags [$cmake_flags]
# Determine CMake toolchain file for this architecture. # Determine CMake toolchain file for this architecture.
toolchain_prefix=flags-gcc
is_mac && toolchain_prefix=llvm-macos
case $arch in case $arch in
32 | x86) toolchain="flags-gcc-i686";; 32 | x86) toolchain="$toolchain_prefix-i686";;
64 | x86_64) toolchain="flags-gcc-x86_64";; 64 | x86_64) toolchain="$toolchain_prefix-x86_64";;
ARM32 | arm32) toolchain="flags-gcc-armv7";; ARM32 | arm32) toolchain="$toolchain_prefix-armv7";;
ARM64 | arm64) toolchain="flags-gcc-aarch64";; ARM64 | arm64) toolchain="$toolchain_prefix-aarch64";;
*) toolchain="flags-gcc-$arch";; *) toolchain="$toolchain_prefix-$arch";;
esac esac
[ ! -e "cmake/$toolchain.cmake" ] && toolchain=flags-gcc
# Perform platform-specific setup. # Perform platform-specific setup.
strip_binary=strip strip_binary=strip
@@ -313,11 +324,22 @@ then
fi fi
# Point CMake to the toolchain file. # Point CMake to the toolchain file.
cmake_flags_extra="$cmake_flags_extra -D \"CMAKE_TOOLCHAIN_FILE=cmake/$toolchain.cmake\"" [ -e "cmake/$toolchain.cmake" ] && cmake_flags_extra="$cmake_flags_extra -D \"CMAKE_TOOLCHAIN_FILE=cmake/$toolchain.cmake\""
elif is_mac elif is_mac
then then
# macOS lacks nproc, but sysctl can do the same job. # macOS lacks nproc, but sysctl can do the same job.
alias nproc='sysctl -n hw.logicalcpu' alias nproc='sysctl -n hw.logicalcpu'
# Install dependencies.
echo [-] Installing dependencies through MacPorts
sudo port selfupdate
sudo port install $(cat .ci/dependencies_macports.txt)
# Point CMake to the toolchain file.
[ -e "cmake/$toolchain.cmake" ] && cmake_flags_extra="$cmake_flags_extra -D \"CMAKE_TOOLCHAIN_FILE=cmake/$toolchain.cmake\""
# Use OpenAL.
cmake_flags_extra="$cmake_flags_extra -D OPENAL=ON"
else else
# Determine Debian architecture. # Determine Debian architecture.
case $arch in case $arch in
@@ -350,18 +372,18 @@ else
[ $length -gt $longest_libpkg ] && longest_libpkg=$length [ $length -gt $longest_libpkg ] && longest_libpkg=$length
done done
# Determine GNU toolchain architecture. # Determine toolchain architecture triplet.
case $arch in case $arch in
x86) arch_gnu="i686-linux-gnu";; x86) arch_triplet="i686-linux-gnu";;
arm32) arch_gnu="arm-linux-gnueabihf";; arm32) arch_triplet="arm-linux-gnueabihf";;
arm64) arch_gnu="aarch64-linux-gnu";; arm64) arch_triplet="aarch64-linux-gnu";;
*) arch_gnu="$arch-linux-gnu";; *) arch_triplet="$arch-linux-gnu";;
esac esac
# Determine library directory name for this architecture. # Determine library directory name for this architecture.
case $arch in case $arch in
x86) libdir="i386-linux-gnu";; x86) libdir="i386-linux-gnu";;
*) libdir="$arch_gnu";; *) libdir="$arch_triplet";;
esac esac
# Create CMake toolchain file. # Create CMake toolchain file.
@@ -369,15 +391,15 @@ else
set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR $arch) set(CMAKE_SYSTEM_PROCESSOR $arch)
set(CMAKE_AR $arch_gnu-ar) set(CMAKE_AR $arch_triplet-ar)
set(CMAKE_ASM_COMPILER $arch_gnu-gcc) set(CMAKE_ASM_COMPILER $arch_triplet-gcc)
set(CMAKE_C_COMPILER $arch_gnu-gcc) set(CMAKE_C_COMPILER $arch_triplet-gcc)
set(CMAKE_CXX_COMPILER $arch_gnu-g++) set(CMAKE_CXX_COMPILER $arch_triplet-g++)
set(CMAKE_LINKER $arch_gnu-ld) set(CMAKE_LINKER $arch_triplet-ld)
set(CMAKE_OBJCOPY $arch_gnu-objcopy) set(CMAKE_OBJCOPY $arch_triplet-objcopy)
set(CMAKE_RANLIB $arch_gnu-ranlib) set(CMAKE_RANLIB $arch_triplet-ranlib)
set(CMAKE_SIZE $arch_gnu-size) set(CMAKE_SIZE $arch_triplet-size)
set(CMAKE_STRIP $arch_gnu-strip) set(CMAKE_STRIP $arch_triplet-strip)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
@@ -389,7 +411,7 @@ set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/$libdir/pkgconfig:/usr/share/$libdir/pkgcon
include("$(pwd)/cmake/$toolchain.cmake") include("$(pwd)/cmake/$toolchain.cmake")
EOF EOF
cmake_flags_extra="$cmake_flags_extra -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake" cmake_flags_extra="$cmake_flags_extra -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake"
strip_binary="$arch_gnu-strip" strip_binary="$arch_triplet-strip"
# Install or update dependencies. # Install or update dependencies.
echo [-] Installing dependencies through apt echo [-] Installing dependencies through apt
@@ -524,8 +546,21 @@ then
fi fi
elif is_mac elif is_mac
then then
# TBD # Archive app bundle with libraries.
: cmake_flags_install=
[ $strip -ne 0 ] && cmake_flags_install="$cmake_flags_install --strip"
cmake --install build --prefix "$(pwd)/archive_tmp" $cmake_flags_install
status=$?
if [ $status -eq 0 ]
then
# Archive Discord Game SDK library.
unzip -j discord_game_sdk.zip "lib/$arch_discord/discord_game_sdk.dylib" -d "archive_tmp/"*".app/Contents/Frameworks"
[ ! -e "archive_tmp/"*".app/Contents/Frameworks/discord_game_sdk.dylib" ] && echo [!] No Discord Game SDK for architecture [$arch_discord]
# Sign app bundle.
codesign --force --deep -s - "archive_tmp/"*".app"
fi
else else
cwd_root=$(pwd) cwd_root=$(pwd)
@@ -643,8 +678,10 @@ then
status=$? status=$?
elif is_mac elif is_mac
then then
# TBD # Create zip. (TODO: dmg)
: cd archive_tmp
zip -r "$cwd/$package_name.zip" .
status=$?
else else
# Determine AppImage runtime architecture. # Determine AppImage runtime architecture.
case $arch in case $arch in

View File

@@ -0,0 +1,10 @@
cmake@3.22.3_0
pkgconfig@0.29.2_0
ninja@1.10.2_4
freetype@2.11.1_0
libsdl2@2.0.20_0
libpng@1.6.37_0
openal-soft@1.21.1_0
rtmidi@5.0.0_0
qt5@5.15.3_0
wget

View File

@@ -32,6 +32,7 @@
#ifndef _WIN32 #ifndef _WIN32
#include <pwd.h> #include <pwd.h>
#include <unistd.h>
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
#include <string.h> #include <string.h>
@@ -125,6 +126,7 @@ uint64_t unique_id = 0;
uint64_t source_hwnd = 0; uint64_t source_hwnd = 0;
#endif #endif
char rom_path[1024] = { '\0'}; /* (O) full path to ROMs */ char rom_path[1024] = { '\0'}; /* (O) full path to ROMs */
rom_path_t rom_paths = { "", NULL }; /* (O) full paths to ROMs */
char log_path[1024] = { '\0'}; /* (O) full path of logfile */ char log_path[1024] = { '\0'}; /* (O) full path of logfile */
char vm_name[1024] = { '\0'}; /* (O) display name of the VM */ char vm_name[1024] = { '\0'}; /* (O) display name of the VM */
@@ -383,6 +385,48 @@ pc_log(const char *fmt, ...)
#define pc_log(fmt, ...) #define pc_log(fmt, ...)
#endif #endif
void
add_rom_path(const char* path)
{
static char cwd[1024];
memset(cwd, 0x00, sizeof(cwd));
rom_path_t* cur_rom_path = &rom_paths;
while (cur_rom_path->next != NULL) {
cur_rom_path = cur_rom_path->next;
}
if (!plat_path_abs((char*)path)) {
/*
* This looks like a relative path.
*
* Add it to the current working directory
* to convert it (back) to an absolute path.
*/
plat_getcwd(cwd, 1024);
plat_path_slash(cwd);
snprintf(cur_rom_path->rom_path, 1024, "%s%s%c", cwd, path, 0);
}
else {
/*
* The user-provided path seems like an
* absolute path, so just use that.
*/
strncpy(cur_rom_path->rom_path, path, 1024);
}
plat_path_slash(cur_rom_path->rom_path);
cur_rom_path->next = calloc(1, sizeof(rom_path_t));
}
// Copied over from Unix code, which in turn is lifted from musl. Needed for parsing XDG_DATA_DIRS.
static char *local_strsep(char **str, const char *sep)
{
char *s = *str, *end;
if (!s) return NULL;
end = s + strcspn(s, sep);
if (*end) *end++ = 0;
else end = 0;
*str = end;
return s;
}
/* /*
* Perform initial startup of the PC. * Perform initial startup of the PC.
@@ -496,6 +540,7 @@ usage:
if ((c+1) == argc) goto usage; if ((c+1) == argc) goto usage;
strcpy(path2, argv[++c]); strcpy(path2, argv[++c]);
add_rom_path(path2);
} else if (!strcasecmp(argv[c], "--config") || } else if (!strcasecmp(argv[c], "--config") ||
!strcasecmp(argv[c], "-C")) { !strcasecmp(argv[c], "-C")) {
if ((c+1) == argc) goto usage; if ((c+1) == argc) goto usage;
@@ -591,26 +636,44 @@ usage:
plat_dir_create(usr_path); plat_dir_create(usr_path);
} }
if (path2[0] == '\0') { if (vmrp) {
char vmrppath[1024] = { 0 };
strcpy(vmrppath, usr_path);
plat_path_slash(vmrppath);
strcat(vmrppath, "roms");
plat_path_slash(vmrppath);
add_rom_path(vmrppath);
if (path2[0] == '\0') {
strcpy(path2, vmrppath);
}
}
{
char default_rom_path[1024] = { 0 };
#if defined(__APPLE__) #if defined(__APPLE__)
getDefaultROMPath(path2); getDefaultROMPath(default_rom_path);
#elif !defined(_WIN32) #elif !defined(_WIN32)
appimage = getenv("APPIMAGE"); appimage = getenv("APPIMAGE");
if (appimage && (appimage[0] != '\0')) { if (appimage && (appimage[0] != '\0')) {
plat_get_dirname(path2, appimage); plat_get_dirname(default_rom_path, appimage);
plat_path_slash(path2); plat_path_slash(default_rom_path);
strcat(path2, "roms"); strcat(default_rom_path, "roms");
plat_path_slash(path2); plat_path_slash(default_rom_path);
} }
#endif #endif
if (default_rom_path[0] == '\0') {
plat_getcwd(default_rom_path, 1024);
plat_path_slash(default_rom_path);
snprintf(default_rom_path, 1024, "%s%s%c", default_rom_path, "roms", 0);
plat_path_slash(default_rom_path);
}
add_rom_path(default_rom_path);
if (path2[0] == '\0') {
strcpy(path2, default_rom_path);
}
} }
if (vmrp && (path2[0] == '\0')) { plat_init_rom_paths();
strcpy(path2, usr_path);
plat_path_slash(path2);
strcat(path2, "roms");
plat_path_slash(path2);
}
/* /*
* If the user provided a path for ROMs, use that * If the user provided a path for ROMs, use that
@@ -708,8 +771,13 @@ usage:
pclog("# VM: %s\n#\n", vm_name); pclog("# VM: %s\n#\n", vm_name);
pclog("# Emulator path: %s\n", exe_path); pclog("# Emulator path: %s\n", exe_path);
pclog("# Userfiles path: %s\n", usr_path); pclog("# Userfiles path: %s\n", usr_path);
if (rom_path[0] != '\0') if (rom_paths.next) {
pclog("# ROM path: %s\n", rom_path); rom_path_t* cur_rom_path = &rom_paths;
while (cur_rom_path->next) {
pclog("# ROM path: %s\n", cur_rom_path->rom_path);
cur_rom_path = cur_rom_path->next;
}
}
else else
#ifndef _WIN32 #ifndef _WIN32
pclog("# ROM path: %sroms/\n", exe_path); pclog("# ROM path: %sroms/\n", exe_path);

View File

@@ -19,6 +19,10 @@ add_executable(86Box 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c
dma.c ddma.c discord.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c dma.c ddma.c discord.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c
mca.c usb.c fifo8.c device.c nvr.c nvr_at.c nvr_ps2.c) mca.c usb.c fifo8.c device.c nvr.c nvr_at.c nvr_ps2.c)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_compile_definitions(_FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE=1 _LARGEFILE64_SOURCE=1)
endif()
if(CPPTHREADS) if(CPPTHREADS)
target_sources(86Box PRIVATE thread.cpp) target_sources(86Box PRIVATE thread.cpp)
endif() endif()

View File

@@ -339,6 +339,30 @@ device_available(const device_t *d)
} }
int
device_has_config(const device_t *d)
{
int c = 0;
device_config_t *config;
if (d == NULL)
return 0;
if (d->config == NULL)
return 0;
config = (device_config_t *) d->config;
while (config->type != -1) {
if (config->type != CONFIG_MAC)
c++;
config++;
}
return (c > 0) ? 1 : 0;
}
int int
device_poll(const device_t *d, int x, int y, int z, int b) device_poll(const device_t *d, int x, int y, int z, int b)
{ {

View File

@@ -202,7 +202,7 @@ hdc_has_config(int hdc)
if (dev == NULL) return(0); if (dev == NULL) return(0);
if (dev->config == NULL) return(0); if (!device_has_config(dev)) return(0);
return(1); return(1);
} }

View File

@@ -154,7 +154,7 @@ fdc_card_has_config(int card)
{ {
if (! fdc_cards[card].device) return(0); if (! fdc_cards[card].device) return(0);
return(fdc_cards[card].device->config ? 1 : 0); return(device_has_config(fdc_cards[card].device) ? 1 : 0);
} }

View File

@@ -147,6 +147,7 @@ extern void device_register_pci_slot(const device_t *d, int device, int type, i
extern void device_speed_changed(void); extern void device_speed_changed(void);
extern void device_force_redraw(void); extern void device_force_redraw(void);
extern void device_get_name(const device_t *d, int bus, char *name); extern void device_get_name(const device_t *d, int bus, char *name);
extern int device_has_config(const device_t *d);
extern int device_is_valid(const device_t *, int m); extern int device_is_valid(const device_t *, int m);

View File

@@ -104,6 +104,7 @@ extern int plat_getcwd(char *bufp, int max);
extern int plat_chdir(char *path); extern int plat_chdir(char *path);
extern void plat_tempfile(char *bufp, char *prefix, char *suffix); extern void plat_tempfile(char *bufp, char *prefix, char *suffix);
extern void plat_get_exe_name(char *s, int size); extern void plat_get_exe_name(char *s, int size);
extern void plat_init_rom_paths();
extern char *plat_get_basename(const char *path); extern char *plat_get_basename(const char *path);
extern void plat_get_dirname(char *dest, const char *path); extern void plat_get_dirname(char *dest, const char *path);
extern char *plat_get_filename(char *s); extern char *plat_get_filename(char *s);

View File

@@ -41,6 +41,15 @@ typedef struct {
} rom_t; } rom_t;
typedef struct rom_path_t {
char rom_path[1024];
struct rom_path_t* next;
} rom_path_t;
extern rom_path_t rom_paths;
extern void add_rom_path(const char* path);
extern uint8_t rom_read(uint32_t addr, void *p); extern uint8_t rom_read(uint32_t addr, void *p);
extern uint16_t rom_readw(uint32_t addr, void *p); extern uint16_t rom_readw(uint32_t addr, void *p);
extern uint32_t rom_readl(uint32_t addr, void *p); extern uint32_t rom_readl(uint32_t addr, void *p);

View File

@@ -69,11 +69,19 @@ rom_fopen(char *fn, char *mode)
fn2 = (char *) malloc(strlen(fn) + 1); fn2 = (char *) malloc(strlen(fn) + 1);
memcpy(fn2, fn, strlen(fn) + 1); memcpy(fn2, fn, strlen(fn) + 1);
if (rom_path[0] != '\0') { if (rom_paths.next) {
rom_path_t* cur_rom_path = &rom_paths;
memset(fn2, 0x00, strlen(fn) + 1); memset(fn2, 0x00, strlen(fn) + 1);
memcpy(fn2, &(fn[5]), strlen(fn) - 4); memcpy(fn2, &(fn[5]), strlen(fn) - 4);
plat_append_filename(temp, rom_path, fn2); while (cur_rom_path->next) {
memset(temp, 0, sizeof(temp));
plat_append_filename(temp, cur_rom_path->rom_path, fn2);
if (rom_present(temp)) {
break;
}
cur_rom_path = cur_rom_path->next;
}
} else { } else {
/* Make sure to make it a backslash, just in case there's malformed /* Make sure to make it a backslash, just in case there's malformed
code calling us that assumes Windows. */ code calling us that assumes Windows. */
@@ -97,17 +105,54 @@ rom_fopen(char *fn, char *mode)
int int
rom_getfile(char *fn, char *s, int size) rom_getfile(char *fn, char *s, int size)
{ {
FILE *f; char temp[1024] = {'\0'};
char *fn2;
int retval = 0;
plat_append_filename(s, exe_path, fn); if ((strstr(fn, "roms/") == fn) || (strstr(fn, "roms\\") == fn)) {
/* Relative path */
fn2 = (char *) malloc(strlen(fn) + 1);
memcpy(fn2, fn, strlen(fn) + 1);
f = plat_fopen(s, "rb"); if (rom_paths.next) {
if (f != NULL) { rom_path_t* cur_rom_path = &rom_paths;
(void)fclose(f); memset(fn2, 0x00, strlen(fn) + 1);
return(1); memcpy(fn2, &(fn[5]), strlen(fn) - 4);
while (cur_rom_path->next) {
memset(temp, 0, sizeof(temp));
plat_append_filename(temp, cur_rom_path->rom_path, fn2);
if (rom_present(temp)) {
strncpy(s, temp, size);
retval = 1;
break;
}
cur_rom_path = cur_rom_path->next;
}
} else {
/* Make sure to make it a backslash, just in case there's malformed
code calling us that assumes Windows. */
if (fn2[4] == '\\')
fn2[4] = '/';
plat_append_filename(temp, exe_path, fn2);
if (rom_present(temp)) {
strncpy(s, temp, size);
retval = 1;
}
} }
return(0); free(fn2);
fn2 = NULL;
} else {
/* Absolute path */
if (rom_present(fn)) {
strncpy(s, fn, size);
retval = 1;
}
}
return(retval);
} }

View File

@@ -630,7 +630,7 @@ network_card_has_config(int card)
{ {
if (! net_cards[card].device) return(0); if (! net_cards[card].device) return(0);
return(net_cards[card].device->config ? 1 : 0); return(device_has_config(net_cards[card].device) ? 1 : 0);
} }

View File

@@ -617,7 +617,7 @@ msgid "ZIP images"
msgstr "Imagens ZIP" msgstr "Imagens ZIP"
msgid "86Box could not find any usable ROM images.\n\nPlease <a href=\"https://github.com/86Box/roms/releases/latest\">download</a> a ROM set and extract it into the \"roms\" directory." msgid "86Box could not find any usable ROM images.\n\nPlease <a href=\"https://github.com/86Box/roms/releases/latest\">download</a> a ROM set and extract it into the \"roms\" directory."
msgstr "O 86Box não conseguiu encontrar nenhuma imagem ROM utilizável.\n\nPor favor, vá a href=\"https://github.com/86Box/roms/releases/latest\">descarregue</a> um pacote ROM e instale-o na pasta \"roms\"." msgstr "O 86Box não conseguiu encontrar nenhuma imagem ROM utilizável.\n\nPor favor, vá <a href=\"https://github.com/86Box/roms/releases/latest\">descarregue</a> um pacote ROM e instale-o na pasta \"roms\"."
msgid "(empty)" msgid "(empty)"
msgstr "(empty)" msgstr "(empty)"

View File

@@ -252,7 +252,7 @@ static MVHDGeom create_drive_vhd_dynamic(const QString& fileName, uint16_t cyl,
static MVHDGeom create_drive_vhd_diff(const QString& fileName, const QString& parentFileName, int blocksize) { static MVHDGeom create_drive_vhd_diff(const QString& fileName, const QString& parentFileName, int blocksize) {
int vhd_error = 0; int vhd_error = 0;
QByteArray filenameBytes = fileName.toUtf8(); QByteArray filenameBytes = fileName.toUtf8();
QByteArray parentFilenameBytes = fileName.toUtf8(); QByteArray parentFilenameBytes = parentFileName.toUtf8();
MVHDCreationOptions options; MVHDCreationOptions options;
options.block_size_in_sectors = blocksize; options.block_size_in_sectors = blocksize;
options.path = filenameBytes.data(); options.path = filenameBytes.data();

View File

@@ -221,9 +221,9 @@ MainWindow::MainWindow(QWidget *parent) :
connect(this, &MainWindow::resizeContents, this, [this](int w, int h) { connect(this, &MainWindow::resizeContents, this, [this](int w, int h) {
if (!QApplication::platformName().contains("eglfs") && vid_resize == 0) { if (!QApplication::platformName().contains("eglfs") && vid_resize == 0) {
w = qRound(w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)); w = (w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.));
int modifiedHeight = qRound(h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)) int modifiedHeight = (h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.))
+ menuBar()->height() + menuBar()->height()
+ (statusBar()->height() * !hide_status_bar) + (statusBar()->height() * !hide_status_bar)
+ (ui->toolBar->height() * !hide_tool_bar); + (ui->toolBar->height() * !hide_tool_bar);

View File

@@ -88,6 +88,8 @@ extern "C" {
#include <86box/timer.h> #include <86box/timer.h>
#include <86box/nvr.h> #include <86box/nvr.h>
#include <86box/plat_dynld.h> #include <86box/plat_dynld.h>
#include <86box/mem.h>
#include <86box/rom.h>
#include <86box/config.h> #include <86box/config.h>
#include <86box/ui.h> #include <86box/ui.h>
#include <86box/discord.h> #include <86box/discord.h>
@@ -382,7 +384,7 @@ extern "C++"
{ {
{0x0405, {"cs-CZ", "Czech (Czech Republic)"} }, {0x0405, {"cs-CZ", "Czech (Czech Republic)"} },
{0x0407, {"de-DE", "German (Germany)"} }, {0x0407, {"de-DE", "German (Germany)"} },
{0x0408, {"en-US", "English (United States)"} }, {0x0409, {"en-US", "English (United States)"} },
{0x0809, {"en-GB", "English (United Kingdom)"} }, {0x0809, {"en-GB", "English (United Kingdom)"} },
{0x0C0A, {"es-ES", "Spanish (Spain)"} }, {0x0C0A, {"es-ES", "Spanish (Spain)"} },
{0x040B, {"fi-FI", "Finnish (Finland)"} }, {0x040B, {"fi-FI", "Finnish (Finland)"} },
@@ -590,3 +592,63 @@ plat_chdir(char *path)
{ {
return QDir::setCurrent(QString(path)) ? 0 : -1; return QDir::setCurrent(QString(path)) ? 0 : -1;
} }
void
plat_init_rom_paths()
{
#if defined __APPLE__
QDir::root().mkpath(QStringLiteral("%1/Documents/86Box/roms/").arg(QDir::homePath()));
add_rom_path(QStringLiteral("%1/Documents/86Box/roms/").arg(QDir::homePath()).toUtf8().constData());
#elif !defined _WIN32
if (getenv("XDG_DATA_HOME")) {
char xdg_rom_path[1024 + 1] = { 0 };
strncpy(xdg_rom_path, getenv("XDG_DATA_HOME"), 1024);
plat_path_slash(xdg_rom_path);
strncat(xdg_rom_path, "86Box/", 1024);
if (!plat_dir_check(xdg_rom_path))
plat_dir_create(xdg_rom_path);
strcat(xdg_rom_path, "roms/");
if (!plat_dir_check(xdg_rom_path))
plat_dir_create(xdg_rom_path);
add_rom_path(xdg_rom_path);
} else {
char home_rom_path[1024] = { 0 };
snprintf(home_rom_path, 1024, "%s/.local/share/86Box/", getenv("HOME") ? getenv("HOME") : QDir::homePath().toUtf8().constData());
if (!plat_dir_check(home_rom_path))
plat_dir_create(home_rom_path);
strcat(home_rom_path, "roms/");
if (!plat_dir_check(home_rom_path))
plat_dir_create(home_rom_path);
add_rom_path(home_rom_path);
}
if (getenv("XDG_DATA_DIRS")) {
char* xdg_rom_paths = strdup(getenv("XDG_DATA_DIRS"));
char* xdg_rom_paths_orig = xdg_rom_paths;
char* cur_xdg_rom_path = NULL;
if (xdg_rom_paths) {
while (xdg_rom_paths[strlen(xdg_rom_paths) - 1] == ':') {
xdg_rom_paths[strlen(xdg_rom_paths) - 1] = '\0';
}
QStringList path_list = QString(xdg_rom_paths).split(":");
for (auto& cur_path : path_list) {
if (cur_path.right(1) != '/')
cur_path.push_back('/');
add_rom_path((cur_path + "86Box/roms").toUtf8().constData());
}
}
free(xdg_rom_paths_orig);
} else {
add_rom_path("/usr/local/share/86Box/roms/");
add_rom_path("/usr/share/86Box/roms/");
}
#elif _WIN32
auto appDataDir = QDir(qEnvironmentVariable("LOCALAPPDATA"));
appDataDir.mkdir("86Box");
appDataDir.mkdir("86Box/roms");
add_rom_path((appDataDir.path().replace("\\","/") + "/86Box/roms").toUtf8().constData());
#endif
}

View File

@@ -153,7 +153,7 @@ scsi_card_has_config(int card)
{ {
if (! scsi_cards[card].device) return(0); if (! scsi_cards[card].device) return(0);
return(scsi_cards[card].device->config ? 1 : 0); return(device_has_config(scsi_cards[card].device) ? 1 : 0);
} }

View File

@@ -186,7 +186,7 @@ sound_card_has_config(int card)
{ {
if (!sound_cards[card].device) if (!sound_cards[card].device)
return 0; return 0;
return sound_cards[card].device->config ? 1 : 0; return device_has_config(sound_cards[card].device) ? 1 : 0;
} }
char * char *

View File

@@ -21,6 +21,8 @@
#include <stdatomic.h> #include <stdatomic.h>
#include <86box/86box.h> #include <86box/86box.h>
#include <86box/mem.h>
#include <86box/rom.h>
#include <86box/keyboard.h> #include <86box/keyboard.h>
#include <86box/mouse.h> #include <86box/mouse.h>
#include <86box/config.h> #include <86box/config.h>
@@ -744,6 +746,66 @@ plat_pause(int p)
} }
} }
void
plat_init_rom_paths()
{
#ifndef __APPLE__
if (getenv("XDG_DATA_HOME")) {
char xdg_rom_path[1024] = { 0 };
strncpy(xdg_rom_path, getenv("XDG_DATA_HOME"), 1024);
plat_path_slash(xdg_rom_path);
strncat(xdg_rom_path, "86Box/", 1024);
if (!plat_dir_check(xdg_rom_path))
plat_dir_create(xdg_rom_path);
strcat(xdg_rom_path, "roms/");
if (!plat_dir_check(xdg_rom_path))
plat_dir_create(xdg_rom_path);
add_rom_path(xdg_rom_path);
} else {
char home_rom_path[1024] = { 0 };
snprintf(home_rom_path, 1024, "%s/.local/share/86Box/", getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir);
if (!plat_dir_check(home_rom_path))
plat_dir_create(home_rom_path);
strcat(home_rom_path, "roms/");
if (!plat_dir_check(home_rom_path))
plat_dir_create(home_rom_path);
add_rom_path(home_rom_path);
}
if (getenv("XDG_DATA_DIRS")) {
char* xdg_rom_paths = strdup(getenv("XDG_DATA_DIRS"));
char* xdg_rom_paths_orig = xdg_rom_paths;
char* cur_xdg_rom_path = NULL;
if (xdg_rom_paths) {
while (xdg_rom_paths[strlen(xdg_rom_paths) - 1] == ':') {
xdg_rom_paths[strlen(xdg_rom_paths) - 1] = '\0';
}
while ((cur_xdg_rom_path = local_strsep(&xdg_rom_paths, ";")) != NULL) {
char real_xdg_rom_path[1024] = { '\0' };
strcat(real_xdg_rom_path, cur_xdg_rom_path);
plat_path_slash(real_xdg_rom_path);
strcat(real_xdg_rom_path, "86Box/roms/");
add_rom_path(real_xdg_rom_path);
}
}
free(xdg_rom_paths_orig);
} else {
add_rom_path("/usr/local/share/86Box/roms/");
add_rom_path("/usr/share/86Box/roms/");
}
#else
char home_rom_path[1024] = { '\0' };
snprintf(home_rom_path, 1024, "%s/Documents/86Box/", getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir);
plat_dir_create(home_rom_path);
strcat(home_rom_path, "roms/");
plat_dir_create(home_rom_path);
add_rom_path(home_rom_path);
#endif
}
bool process_media_commands_3(uint8_t* id, char* fn, uint8_t* wp, int cmdargc) bool process_media_commands_3(uint8_t* id, char* fn, uint8_t* wp, int cmdargc)
{ {
bool err = false; bool err = false;

View File

@@ -364,7 +364,7 @@ video_card_has_config(int card)
{ {
if (video_cards[card].device == NULL) return(0); if (video_cards[card].device == NULL) return(0);
return(video_cards[card].device->config ? 1 : 0); return(device_has_config(video_cards[card].device) ? 1 : 0);
} }

View File

@@ -45,6 +45,8 @@
#include <86box/timer.h> #include <86box/timer.h>
#include <86box/nvr.h> #include <86box/nvr.h>
#include <86box/video.h> #include <86box/video.h>
#include <86box/mem.h>
#include <86box/rom.h>
#define GLOBAL #define GLOBAL
#include <86box/plat.h> #include <86box/plat.h>
#include <86box/ui.h> #include <86box/ui.h>
@@ -910,6 +912,30 @@ plat_mmap(size_t size, uint8_t executable)
} }
void
plat_init_rom_paths()
{
wchar_t appdata_dir[1024] = { L'\0' };
if (_wgetenv("LOCALAPPDATA") && _wgetenv("LOCALAPPDATA")[0] != L'\0') {
char appdata_dir_a[1024] = { '\0' };
size_t len = 0;
wcsncpy(appdata_dir, _wgetenv("LOCALAPPDATA"), 1024);
len = wcslen(appdata_dir);
if (appdata_dir[len - 1] != L'\\') {
appdata_dir[len] = L'\\';
appdata_dir[len + 1] = L'\0';
}
wcscat(appdata_dir, "86box");
CreateDirectoryW(appdata_dir, NULL);
wcscat(appdata_dir, "\\roms");
CreateDirectoryW(appdata_dir, NULL);
wcscat(appdata_dir, "\\");
c16stombs(appdata_dir_a, appdata_dir, 1024);
add_rom_path(appdata_dir_a);
}
}
void void
plat_munmap(void *ptr, size_t size) plat_munmap(void *ptr, size_t size)
{ {