From 13371d03bdd2c126fbe161c83e23168b4ded9fe4 Mon Sep 17 00:00:00 2001 From: jvernet Date: Fri, 19 Nov 2021 12:41:31 +0100 Subject: [PATCH 1/4] macOSX Rom path detecttion --- src/86box.c | 27 +++++++++++++++++---------- src/CMakeLists.txt | 3 +++ src/mac/CMakeLists.txt | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 src/mac/CMakeLists.txt diff --git a/src/86box.c b/src/86box.c index 908bef06f..e86620c0f 100644 --- a/src/86box.c +++ b/src/86box.c @@ -33,6 +33,7 @@ #ifdef __APPLE__ #include #include +#include #ifdef __aarch64__ #include #endif @@ -147,24 +148,24 @@ int video_vsync = 0; /* (C) video */ int video_framerate = -1; /* (C) video */ char video_shader[512] = { '\0' }; /* (C) video */ int serial_enabled[SERIAL_MAX] = {0,0}; /* (C) enable serial ports */ -int bugger_enabled = 0; /* (C) enable ISAbugger */ +int bugger_enabled = 0; /* (C) enable ISAbugger */ int postcard_enabled = 0; /* (C) enable POST card */ int isamem_type[ISAMEM_MAX] = { 0,0,0,0 }; /* (C) enable ISA mem cards */ -int isartc_type = 0; /* (C) enable ISA RTC card */ +int isartc_type = 0; /* (C) enable ISA RTC card */ int gfxcard = 0; /* (C) graphics/video card */ int sound_is_float = 1; /* (C) sound uses FP values */ -int GAMEBLASTER = 0; /* (C) sound option */ -int GUS = 0; /* (C) sound option */ +int GAMEBLASTER = 0; /* (C) sound option */ +int GUS = 0; /* (C) sound option */ int SSI2001 = 0; /* (C) sound option */ -int voodoo_enabled = 0; /* (C) video option */ +int voodoo_enabled = 0; /* (C) video option */ uint32_t mem_size = 0; /* (C) memory size */ int cpu_use_dynarec = 0; /* (C) cpu uses/needs Dyna */ -int cpu = 0; /* (C) cpu type */ +int cpu = 0; /* (C) cpu type */ int fpu_type = 0; /* (C) fpu type */ int time_sync = 0; /* (C) enable time sync */ int confirm_reset = 1; /* (C) enable reset confirmation */ -int confirm_exit = 1; /* (C) enable exit confirmation */ -int confirm_save = 1; /* (C) enable save confirmation */ +int confirm_exit = 1; /* (C) enable exit confirmation */ +int confirm_save = 1; /* (C) enable save confirmation */ #ifdef USE_DISCORD int enable_discord = 0; /* (C) enable Discord integration */ #endif @@ -188,7 +189,7 @@ char usr_path[1024]; /* path (dir) of user data */ char cfg_path[1024]; /* full path of config file */ FILE *stdlog = NULL; /* file to log output to */ int scrnsz_x = SCREEN_RES_X; /* current screen size, X */ -int scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */ +int scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */ int config_changed; /* config has changed */ int title_update; int framecountx = 0; @@ -587,12 +588,18 @@ usage: if (vmrp && (path2[0] == '\0')) { #ifdef __APPLE__ - sprintf("%s/Library/Application Support/86Box/roms", getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir); + getDefaultROMPath(path2); + // This will return an absolut path to ~/Library/Application Support/bundleidentifier #else strcpy(path2, usr_path); plat_path_slash(path2); strcat(path2, "roms"); #endif + /// + /// TODO: Add Plateform specific getDefaultROMPath to hide the awkfull code below + /// + /// Date: Fri, 19 Nov 2021 13:05:33 +0100 Subject: [PATCH 2/4] Update CMakeLists.txt --- src/mac/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mac/CMakeLists.txt b/src/mac/CMakeLists.txt index ef3ce12b6..ba2d53e52 100644 --- a/src/mac/CMakeLists.txt +++ b/src/mac/CMakeLists.txt @@ -1 +1,3 @@ include_directories("./mac") +target_sources(86Box PUBLIC "./mac/MacOSCGlue.m") + From 46af2a7a8f2030d54529072711efd600e19ea42a Mon Sep 17 00:00:00 2001 From: jvernet Date: Fri, 19 Nov 2021 16:42:43 +0100 Subject: [PATCH 3/4] MacOSX Default ROM PATH --- src/86box.c | 20 +++++++++++++------- src/CMakeLists.txt | 9 ++++++--- src/mac/CMakeLists.txt | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/86box.c b/src/86box.c index e86620c0f..6b3f090dc 100644 --- a/src/86box.c +++ b/src/86box.c @@ -33,7 +33,7 @@ #ifdef __APPLE__ #include #include -#include +#include "mac/macOSXGlue.h" #ifdef __aarch64__ #include #endif @@ -418,6 +418,9 @@ pc_init(int argc, char *argv[]) plat_getcwd(usr_path, sizeof(usr_path) - 1); plat_getcwd(rom_path, sizeof(rom_path) - 1); + printf("JV:usr_path %s\n",usr_path); + printf("JV:rom_path %s\n",usr_path); + memset(path, 0x00, sizeof(path)); memset(path2, 0x00, sizeof(path)); @@ -586,20 +589,23 @@ usage: plat_dir_create(usr_path); } + // TODO: Path detection should be rewrite. Write function per OS rather than how it's done now +#ifdef __APPLE__ + //Get and create default rom path for MacOsX + getDefaultROMPath(path2); + // This will return an absolut path to ~/Library/Application Support/bundleidentifierk/roms +#endif + if (vmrp && (path2[0] == '\0')) { #ifdef __APPLE__ +//NO COMMAND LINE ARG for MacOsX when aunched from Finder, so this will never run?? getDefaultROMPath(path2); - // This will return an absolut path to ~/Library/Application Support/bundleidentifier + // This will return an absolut path to ~/Library/Application Support/bundleidentifierk/roms #else strcpy(path2, usr_path); plat_path_slash(path2); strcat(path2, "roms"); #endif - /// - /// TODO: Add Plateform specific getDefaultROMPath to hide the awkfull code below - /// - /// Date: Fri, 19 Nov 2021 16:57:38 +0100 Subject: [PATCH 4/4] MacOsX Compilation --- src/86box.c | 17 +++++------------ src/CMakeLists.txt | 30 +++++++++++++++++++----------- src/video/vid_cl54xx.c | 2 +- src/win/win_ui.c | 6 +++--- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/86box.c b/src/86box.c index 6b3f090dc..bbb97368c 100644 --- a/src/86box.c +++ b/src/86box.c @@ -394,6 +394,7 @@ pc_init(int argc, char *argv[]) { char path[2048], path2[2048]; char *cfg = NULL, *p; + char mac_rom_path[2048]; char temp[128]; struct tm *info; time_t now; @@ -589,23 +590,15 @@ usage: plat_dir_create(usr_path); } - // TODO: Path detection should be rewrite. Write function per OS rather than how it's done now -#ifdef __APPLE__ - //Get and create default rom path for MacOsX - getDefaultROMPath(path2); - // This will return an absolut path to ~/Library/Application Support/bundleidentifierk/roms -#endif + #ifdef __APPLE__ + getDefaultROMPath(mac_rom_path); + strcpy(path2, mac_rom_path); + #endif if (vmrp && (path2[0] == '\0')) { -#ifdef __APPLE__ -//NO COMMAND LINE ARG for MacOsX when aunched from Finder, so this will never run?? - getDefaultROMPath(path2); - // This will return an absolut path to ~/Library/Application Support/bundleidentifierk/roms -#else strcpy(path2, usr_path); plat_path_slash(path2); strcat(path2, "roms"); -#endif plat_path_slash(path2); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5f522b17f..910c5ee65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,24 +16,33 @@ # # Prepare the macOS app bundle icon depending on the release channel -if(RELEASE_BUILD) - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/release/86Box.icns) -elseif(BETA_BUILD) - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/beta/86Box.icns) -elseif(ALPHA_BUILD) - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/dev/86Box.icns) -else() - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/branch/86Box.icns) -endif() +set(APP_ICON_MACOSX) +if (APPLE) + if(RELEASE_BUILD) + set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/release/86Box.icns) + elseif(BETA_BUILD) + set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/beta/86Box.icns) + elseif(ALPHA_BUILD) + set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/dev/86Box.icns) + else() + set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/branch/86Box.icns) + endif() set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") +endif() + +#Adding the macOS glue for ROM paths +set(MAC_GLUE) +if (APPLE) + set(MAC_GLUE ${CMAKE_CURRENT_SOURCE_DIR}/mac/macOSXGlue.m) +endif() # WIN32 marks us as a GUI app on Windows # MACOSX_BUNDLE prepares a macOS application bundle including with the app icon add_executable(86Box WIN32 MACOSX_BUNDLE 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c dma.c ddma.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c mca.c usb.c - device.c nvr.c nvr_at.c nvr_ps2.c ${APP_ICON_MACOSX}) + device.c nvr.c nvr_at.c nvr_ps2.c ${APP_ICON_MACOSX} ${MAC_GLUE}) if(NEW_DYNAREC) add_compile_definitions(USE_NEW_DYNAREC) @@ -187,7 +196,6 @@ endif() if(APPLE) set(APPS ${CMAKE_CURRENT_BINARY_DIR}/86Box.app) install(CODE " - include(InstallRequiredSystemLibraries) include(BundleUtilities) fixup_bundle(\"${APPS}\" \"\" \"\")" COMPONENT Runtime) diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index 3055de90a..6cc24affa 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -42,7 +42,7 @@ #define BIOS_GD5401_PATH "roms/video/cirruslogic/avga1.rom" #define BIOS_GD5402_PATH "roms/video/cirruslogic/avga2.rom" -#define BIOS_GD5402_ONBOARD_PATH "roms/machines/cbm_sl386sx25/c000.rom" +#define BIOS_GD5402_ONBOARD_PATH "roms/machines/cmdsl386sx25/c000.rom" #define BIOS_GD5420_PATH "roms/video/cirruslogic/5420.vbi" #define BIOS_GD5422_PATH "roms/video/cirruslogic/cl5422.bin" #define BIOS_GD5426_DIAMOND_A1_ISA_PATH "roms/video/cirruslogic/diamond5426.bin" diff --git a/src/win/win_ui.c b/src/win/win_ui.c index e5ab4958c..60d63b99e 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -1270,6 +1270,9 @@ ui_init(int nCmdShow) tdconfig.pButtons = tdbuttons; tdconfig.pfCallback = TaskDialogProcedure; + /* Load the desired iconset */ + win_load_icon_set(); + /* Start settings-only mode if requested. */ if (settings_only) { if (! pc_init_modules()) { @@ -1404,9 +1407,6 @@ ui_init(int nCmdShow) ResetAllMenus(); media_menu_init(); - /* Load the desired iconset */ - win_load_icon_set(); - /* Make the window visible on the screen. */ ShowWindow(hwnd, nCmdShow);