From 2e68fe044ea09b8928615e1432f654ff3f2520dc Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Sun, 29 Aug 2021 00:01:20 -0400 Subject: [PATCH 1/9] Add files via upload --- src/include/86box/resource.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 7d2233ea6..7168ce5ba 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -164,6 +164,7 @@ #define IDC_CONFIGURE_GUS 1049 #define IDC_COMBO_MIDI_IN 1050 #define IDC_CONFIGURE_CMS 1051 +#define IDC_CONFIGURE_SSI 1052 #define IDC_COMBO_NET_TYPE 1060 /* network config */ #define IDC_COMBO_PCAP 1061 From b9342ec1ea88c9946172b7718b486ab9c14740c5 Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Sun, 29 Aug 2021 00:02:50 -0400 Subject: [PATCH 2/9] Add files via upload --- src/sound/snd_ssi2001.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index ad65a9010..bd4e70ea9 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -65,7 +65,8 @@ void *ssi2001_init(const device_t *info) ssi2001->psid = sid_init(); sid_reset(ssi2001->psid); - io_sethandler(0x0280, 0x0020, ssi2001_read, NULL, NULL, ssi2001_write, NULL, NULL, ssi2001); + uint16_t addr = device_get_config_hex16("base"); + io_sethandler(addr, 0x0020, ssi2001_read, NULL, NULL, ssi2001_write, NULL, NULL, ssi2001); sound_add_handler(ssi2001_get_buffer, ssi2001); return ssi2001; } @@ -79,11 +80,38 @@ void ssi2001_close(void *p) free(ssi2001); } +static const device_config_t ssi2001_config[] = +{ + { + "base", "Address", CONFIG_HEX16, "", 0x280, "", { 0 }, + { + { + "0x280", 0x280 + }, + { + "0x2A0", 0x2A0 + }, + { + "0x2C0", 0x2C0 + }, + { + "0x2E0", 0x2E0 + }, + { + "" + } + } + }, + { + "", "", -1 + } +}; + const device_t ssi2001_device = { "Innovation SSI-2001", 0, 0, ssi2001_init, ssi2001_close, NULL, { NULL }, NULL, NULL, - NULL + ssi2001_config }; From 4cbba570a9898a918db8db35932387df5b915e4c Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Sun, 29 Aug 2021 00:03:33 -0400 Subject: [PATCH 3/9] Add files via upload --- src/win/86Box.rc | 1 + src/win/win_settings.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 78b37c697..d6e98e6ee 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -519,6 +519,7 @@ BEGIN CONTROL "Innovation SSI-2001",IDC_CHECK_SSI,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,84,95,10 + PUSHBUTTON "Configure",IDC_CONFIGURE_SSI,214,82,46,12 CONTROL "CMS / Game Blaster",IDC_CHECK_CMS,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,102,95,10 diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 4a7dbc0bb..7e90ef1ba 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -1380,6 +1380,7 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) settings_set_check(hdlg, IDC_CHECK_GUS, temp_GUS); settings_enable_window(hdlg, IDC_CONFIGURE_GUS, temp_GUS); settings_set_check(hdlg, IDC_CHECK_SSI, temp_SSI2001); + settings_enable_window(hdlg, IDC_CONFIGURE_SSI, temp_SSI2001); settings_set_check(hdlg, IDC_CHECK_FLOAT, temp_float); free(lptsTemp); @@ -1456,6 +1457,16 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_CONFIGURE_GUS: temp_deviceconfig |= deviceconfig_open(hdlg, (void *)&gus_device); break; + + case IDC_CHECK_SSI: + temp_SSI2001 = settings_get_check(hdlg, IDC_CHECK_SSI); + + settings_enable_window(hdlg, IDC_CONFIGURE_SSI, temp_SSI2001); + break; + + case IDC_CONFIGURE_SSI: + temp_deviceconfig |= deviceconfig_open(hdlg, &ssi2001_device); + break; } return FALSE; From 5b880cd8046a7ae9b3c30263eca79a48cc1fc6f4 Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Sun, 29 Aug 2021 01:38:45 -0400 Subject: [PATCH 4/9] Added correct IRQs for Roland MPU-IPC-T card and corrected typo --- src/sound/snd_mpu401.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/sound/snd_mpu401.c b/src/sound/snd_mpu401.c index b407ceea9..0f6e420b7 100644 --- a/src/sound/snd_mpu401.c +++ b/src/sound/snd_mpu401.c @@ -1674,7 +1674,7 @@ mpu401_init(mpu_t *mpu, uint16_t addr, int irq, int mode, int receive_input) mpu->mode = M_UART; mpu->addr = addr; - /* Expalantion: + /* Explanation: MPU-401 starting in intelligent mode = Full MPU-401 intelligent mode capability; MPU-401 starting in UART mode = Reduced MPU-401 intelligent mode capability seen on the Sound Blaster 16/AWE32, only supporting commands 3F (set UART mode) and FF (reset). */ @@ -1817,10 +1817,10 @@ static const device_config_t mpu401_standalone_config[] = } }, { - "irq", "MPU-401 IRQ", CONFIG_SELECTION, "", 9, "", { 0 }, + "irq", "MPU-401 IRQ", CONFIG_SELECTION, "", 2, "", { 0 }, { { - "IRQ 9", 9 + "IRQ 2", 2 }, { "IRQ 3", 3 @@ -1834,9 +1834,6 @@ static const device_config_t mpu401_standalone_config[] = { "IRQ 7", 7 }, - { - "IRQ 10", 10 - }, { "" } From 0468164c2bb493345604036cfb441acb0c953418 Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Sun, 29 Aug 2021 02:04:22 -0400 Subject: [PATCH 5/9] Add files via upload --- src/sound/snd_mpu401.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sound/snd_mpu401.c b/src/sound/snd_mpu401.c index 0f6e420b7..571ee8085 100644 --- a/src/sound/snd_mpu401.c +++ b/src/sound/snd_mpu401.c @@ -1808,6 +1808,9 @@ static const device_config_t mpu401_standalone_config[] = { "0x300", 0x300 }, + { + "0x320", 0x320 + }, { "0x330", 0x330 }, @@ -1831,6 +1834,9 @@ static const device_config_t mpu401_standalone_config[] = { "IRQ 5", 5 }, + { + "IRQ 6", 6 + }, { "IRQ 7", 7 }, From 5272ddda562a68ba9205fbcb213571ea9c0927d5 Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Sun, 29 Aug 2021 05:51:47 -0400 Subject: [PATCH 6/9] Restored previous MPU-401 code --- src/sound/snd_mpu401.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/sound/snd_mpu401.c b/src/sound/snd_mpu401.c index 571ee8085..b407ceea9 100644 --- a/src/sound/snd_mpu401.c +++ b/src/sound/snd_mpu401.c @@ -1674,7 +1674,7 @@ mpu401_init(mpu_t *mpu, uint16_t addr, int irq, int mode, int receive_input) mpu->mode = M_UART; mpu->addr = addr; - /* Explanation: + /* Expalantion: MPU-401 starting in intelligent mode = Full MPU-401 intelligent mode capability; MPU-401 starting in UART mode = Reduced MPU-401 intelligent mode capability seen on the Sound Blaster 16/AWE32, only supporting commands 3F (set UART mode) and FF (reset). */ @@ -1808,9 +1808,6 @@ static const device_config_t mpu401_standalone_config[] = { "0x300", 0x300 }, - { - "0x320", 0x320 - }, { "0x330", 0x330 }, @@ -1820,10 +1817,10 @@ static const device_config_t mpu401_standalone_config[] = } }, { - "irq", "MPU-401 IRQ", CONFIG_SELECTION, "", 2, "", { 0 }, + "irq", "MPU-401 IRQ", CONFIG_SELECTION, "", 9, "", { 0 }, { { - "IRQ 2", 2 + "IRQ 9", 9 }, { "IRQ 3", 3 @@ -1835,10 +1832,10 @@ static const device_config_t mpu401_standalone_config[] = "IRQ 5", 5 }, { - "IRQ 6", 6 + "IRQ 7", 7 }, { - "IRQ 7", 7 + "IRQ 10", 10 }, { "" From a491b3a35c910b094f5383bc238509585bea3091 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 18 Sep 2021 21:33:13 +0200 Subject: [PATCH 7/9] Reverted the meaning of video_fullscreen_first to what it used to be. --- src/config.c | 3 ++- src/win/win.c | 2 +- src/win/win_ui.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index 6d26fe9c6..ec2a19839 100644 --- a/src/config.c +++ b/src/config.c @@ -505,7 +505,7 @@ load_general(void) video_fullscreen_scale = config_get_int(cat, "video_fullscreen_scale", 0); - video_fullscreen_first = config_get_int(cat, "video_fullscreen_first", 0); + video_fullscreen_first = config_get_int(cat, "video_fullscreen_first", 1); video_filter_method = config_get_int(cat, "video_filter_method", 1); @@ -2018,6 +2018,7 @@ config_load(void) gfxcard = video_get_video_from_internal_name("cga"); vid_api = plat_vidapi("default"); vid_resize = 0; + video_fullscreen_first = 1; time_sync = TIME_SYNC_ENABLED; hdc_current = hdc_get_from_internal_name("none"); serial_enabled[0] = 1; diff --git a/src/win/win.c b/src/win/win.c index 6d7cc86f9..45d32bd8e 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -1050,7 +1050,7 @@ plat_setfullscreen(int on) if ((!!(on & 1)) == (!!video_fullscreen)) return; - if (on && (start_in_fullscreen || video_fullscreen_first)) { + if (on && video_fullscreen_first) { video_fullscreen |= 2; if (ui_msgbox_header(MBX_INFO | MBX_DONTASK, (wchar_t *) IDS_2134, (wchar_t *) IDS_2052) == 10) { video_fullscreen_first = 0; diff --git a/src/win/win_ui.c b/src/win/win_ui.c index a778d60e7..6a38045c9 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -1427,7 +1427,7 @@ ui_init(int nCmdShow) } /* Initialize the mouse module. */ - if (!start_in_fullscreen && !video_fullscreen_first) + if (!start_in_fullscreen) win_mouse_init(); /* @@ -1459,7 +1459,7 @@ ui_init(int nCmdShow) plat_resize(scrnsz_x, scrnsz_y); /* Initialize the rendering window, or fullscreen. */ - if (start_in_fullscreen || video_fullscreen_first) + if (start_in_fullscreen) plat_setfullscreen(3); /* Fire up the machine. */ From e8908ee1b40ecbcb62303492e05263f28c22ed5e Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Sat, 18 Sep 2021 22:01:13 -0400 Subject: [PATCH 8/9] Add files via upload --- src/sound/snd_audiopci.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/sound/snd_audiopci.c b/src/sound/snd_audiopci.c index a24978750..f9ecb7d1f 100644 --- a/src/sound/snd_audiopci.c +++ b/src/sound/snd_audiopci.c @@ -802,7 +802,6 @@ es1371_outb(uint16_t port, uint8_t val, void *p) Addressable as byte, word, longword */ case 0x18: dev->legacy_ctrl |= LEGACY_INT; - // nmi = 0; break; case 0x1a: old_legacy_ctrl = dev->legacy_ctrl; @@ -879,7 +878,6 @@ es1371_outw(uint16_t port, uint16_t val, void *p) Addressable as byte, word, longword */ case 0x18: dev->legacy_ctrl |= LEGACY_INT; - // nmi = 0; break; case 0x1a: old_legacy_ctrl = dev->legacy_ctrl; @@ -1032,7 +1030,6 @@ es1371_outl(uint16_t port, uint32_t val, void *p) old_legacy_ctrl = dev->legacy_ctrl; dev->legacy_ctrl = (dev->legacy_ctrl & 0x0000ffff) | (val & 0xffff0000); dev->legacy_ctrl |= LEGACY_INT; - // nmi = 0; es1371_update_irqs(dev); update_legacy(dev, old_legacy_ctrl); break; @@ -1239,17 +1236,17 @@ update_legacy(es1371_t *dev, uint32_t old_legacy_ctrl) if (old_legacy_ctrl & LEGACY_CAPTURE_CODEC) { switch ((old_legacy_ctrl >> LEGACY_CODEC_ADDR_SHIFT) & 3) { case 0: - io_removehandler(0x5300, 0x0080, + io_removehandler(0x0530, 0x0008, capture_read_codec, NULL, NULL, capture_write_codec, NULL, NULL, dev); break; case 2: - io_removehandler(0xe800, 0x0080, + io_removehandler(0x0e80, 0x0008, capture_read_codec, NULL, NULL, capture_write_codec,NULL,NULL, dev); break; case 3: - io_removehandler(0xf400, 0x0080, + io_removehandler(0x0f40, 0x0008, capture_read_codec, NULL, NULL, capture_write_codec, NULL, NULL, dev); break; @@ -1326,17 +1323,17 @@ update_legacy(es1371_t *dev, uint32_t old_legacy_ctrl) if (dev->legacy_ctrl & LEGACY_CAPTURE_CODEC) { switch ((dev->legacy_ctrl >> LEGACY_CODEC_ADDR_SHIFT) & 3) { case 0: - io_sethandler(0x5300, 0x0080, + io_sethandler(0x0530, 0x0008, capture_read_codec, NULL, NULL, capture_write_codec, NULL, NULL, dev); break; case 2: - io_sethandler(0xe800, 0x0080, + io_sethandler(0x0e80, 0x0008, capture_read_codec, NULL, NULL, capture_write_codec, NULL, NULL, dev); break; case 3: - io_sethandler(0xf400, 0x0080, + io_sethandler(0x0f40, 0x0008, capture_read_codec, NULL, NULL, capture_write_codec, NULL, NULL, dev); break; From 5af94b6759a9c4a31996982103b248b71ac36674 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 19 Sep 2021 14:01:25 +0200 Subject: [PATCH 9/9] Rewrote thread.c so it uses Win32 threads on Windows. --- src/thread.c | 214 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 176 insertions(+), 38 deletions(-) diff --git a/src/thread.c b/src/thread.c index d95c337d1..3dd41ed08 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1,52 +1,191 @@ -#include +#include #include +#include #include -#include -#include +#ifdef __APPLE__ +#include +#endif #include <86box/86box.h> #include <86box/plat.h> +#if (defined WIN32) || (defined _WIN32) || (defined _WIN32) +#include +#include + +typedef struct { + HANDLE handle; +} win_event_t; + + +thread_t * +thread_create(void (*func)(void *param), void *param) +{ + uintptr_t bt = _beginthread(func, 0, param); + return((thread_t *)bt); +} + + +int +thread_wait(thread_t *arg, int timeout) +{ + if (arg == NULL) return(0); + + if (timeout == -1) + timeout = INFINITE; + + if (WaitForSingleObject(arg, timeout)) return(1); + + return(0); +} + + +event_t * +thread_create_event(void) +{ + win_event_t *ev = malloc(sizeof(win_event_t)); + + ev->handle = CreateEvent(NULL, FALSE, FALSE, NULL); + + return((event_t *)ev); +} + + +void +thread_set_event(event_t *arg) +{ + win_event_t *ev = (win_event_t *)arg; + + if (arg == NULL) return; + + SetEvent(ev->handle); +} + + +void +thread_reset_event(event_t *arg) +{ + win_event_t *ev = (win_event_t *)arg; + + if (arg == NULL) return; + + ResetEvent(ev->handle); +} + + +int +thread_wait_event(event_t *arg, int timeout) +{ + win_event_t *ev = (win_event_t *)arg; + + if (arg == NULL) return(0); + + if (ev->handle == NULL) return(0); + + if (timeout == -1) + timeout = INFINITE; + + if (WaitForSingleObject(ev->handle, timeout)) return(1); + + return(0); +} + + +void +thread_destroy_event(event_t *arg) +{ + win_event_t *ev = (win_event_t *)arg; + + if (arg == NULL) return; + + CloseHandle(ev->handle); + + free(ev); +} + + +mutex_t * +thread_create_mutex(void) +{ + mutex_t *mutex = malloc(sizeof(CRITICAL_SECTION)); + + InitializeCriticalSection(mutex); + + return mutex; +} + + +mutex_t * +thread_create_mutex_with_spin_count(unsigned int spin_count) +{ + mutex_t *mutex = malloc(sizeof(CRITICAL_SECTION)); + + InitializeCriticalSectionAndSpinCount(mutex, spin_count); + + return mutex; +} + + +int +thread_wait_mutex(mutex_t *mutex) +{ + if (mutex == NULL) return(0); + + LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex; + + EnterCriticalSection(critsec); + + return 1; +} + + +int +thread_release_mutex(mutex_t *mutex) +{ + if (mutex == NULL) return(0); + + LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex; + + LeaveCriticalSection(critsec); + + return 1; +} + + +void +thread_close_mutex(mutex_t *mutex) +{ + if (mutex == NULL) return; + + LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex; + + DeleteCriticalSection(critsec); + + free(critsec); +} +#else +#include +#include typedef struct event_pthread_t { pthread_cond_t cond; pthread_mutex_t mutex; - int state; + int state; } event_pthread_t; -typedef struct thread_param -{ - void (*thread_rout)(void*); - void * param; -} thread_param; - - typedef struct pt_mutex_t { pthread_mutex_t mutex; } pt_mutex_t; -void * -thread_run_wrapper(thread_param* arg) -{ - thread_param localparam = *arg; - free(arg); - localparam.thread_rout(localparam.param); - return NULL; -} - - thread_t * thread_create(void (*thread_rout)(void *param), void *param) { pthread_t *thread = malloc(sizeof(pthread_t)); - thread_param *thrparam = malloc(sizeof(thread_param)); - thrparam->thread_rout = thread_rout; - thrparam->param = param; - pthread_create(thread, NULL, (void* (*)(void*))thread_run_wrapper, thrparam); + pthread_create(thread, NULL, (void*)thread_rout, param); return thread; } @@ -101,10 +240,13 @@ thread_wait_event(event_t *handle, int timeout) event_pthread_t *event = (event_pthread_t *)handle; struct timespec abstime; -#ifdef HAS_TIMESPEC_GET - timespec_get(&abstime, TIME_UTC); -#else +#ifdef __linux__ clock_gettime(CLOCK_REALTIME, &abstime); +#else + struct timeval now; + gettimeofday(&now, 0); + abstime.tv_sec = now.tv_sec; + abstime.tv_nsec = now.tv_usec*1000UL; #endif abstime.tv_nsec += (timeout % 1000) * 1000000; abstime.tv_sec += (timeout / 1000); @@ -156,26 +298,21 @@ thread_create_mutex_with_spin_count(unsigned int spin_count) } -int +void thread_wait_mutex(mutex_t *_mutex) { - if (_mutex == NULL) - return(0); pt_mutex_t *mutex = (pt_mutex_t *)_mutex; - return - pthread_mutex_lock(&mutex->mutex) != 0; + pthread_mutex_lock(&mutex->mutex); } -int -thread_release_mutex(mutex_t *_mutex) +void +thread_unlock_mutex(mutex_t *_mutex) { - if (_mutex == NULL) - return(0); pt_mutex_t *mutex = (pt_mutex_t *)_mutex; - return pthread_mutex_unlock(&mutex->mutex) != 0; + pthread_mutex_unlock(&mutex->mutex); } @@ -188,3 +325,4 @@ thread_close_mutex(mutex_t *_mutex) free(mutex); } +#endif