Merge remote-tracking branch 'origin/master' into feature/machine_and_kb
This commit is contained in:
@@ -505,7 +505,7 @@ load_general(void)
|
|||||||
|
|
||||||
video_fullscreen_scale = config_get_int(cat, "video_fullscreen_scale", 0);
|
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);
|
video_filter_method = config_get_int(cat, "video_filter_method", 1);
|
||||||
|
|
||||||
@@ -2024,6 +2024,7 @@ config_load(void)
|
|||||||
gfxcard = video_get_video_from_internal_name("cga");
|
gfxcard = video_get_video_from_internal_name("cga");
|
||||||
vid_api = plat_vidapi("default");
|
vid_api = plat_vidapi("default");
|
||||||
vid_resize = 0;
|
vid_resize = 0;
|
||||||
|
video_fullscreen_first = 1;
|
||||||
time_sync = TIME_SYNC_ENABLED;
|
time_sync = TIME_SYNC_ENABLED;
|
||||||
hdc_current = hdc_get_from_internal_name("none");
|
hdc_current = hdc_get_from_internal_name("none");
|
||||||
serial_enabled[0] = 1;
|
serial_enabled[0] = 1;
|
||||||
|
@@ -802,7 +802,6 @@ es1371_outb(uint16_t port, uint8_t val, void *p)
|
|||||||
Addressable as byte, word, longword */
|
Addressable as byte, word, longword */
|
||||||
case 0x18:
|
case 0x18:
|
||||||
dev->legacy_ctrl |= LEGACY_INT;
|
dev->legacy_ctrl |= LEGACY_INT;
|
||||||
// nmi = 0;
|
|
||||||
break;
|
break;
|
||||||
case 0x1a:
|
case 0x1a:
|
||||||
old_legacy_ctrl = dev->legacy_ctrl;
|
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 */
|
Addressable as byte, word, longword */
|
||||||
case 0x18:
|
case 0x18:
|
||||||
dev->legacy_ctrl |= LEGACY_INT;
|
dev->legacy_ctrl |= LEGACY_INT;
|
||||||
// nmi = 0;
|
|
||||||
break;
|
break;
|
||||||
case 0x1a:
|
case 0x1a:
|
||||||
old_legacy_ctrl = dev->legacy_ctrl;
|
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;
|
old_legacy_ctrl = dev->legacy_ctrl;
|
||||||
dev->legacy_ctrl = (dev->legacy_ctrl & 0x0000ffff) | (val & 0xffff0000);
|
dev->legacy_ctrl = (dev->legacy_ctrl & 0x0000ffff) | (val & 0xffff0000);
|
||||||
dev->legacy_ctrl |= LEGACY_INT;
|
dev->legacy_ctrl |= LEGACY_INT;
|
||||||
// nmi = 0;
|
|
||||||
es1371_update_irqs(dev);
|
es1371_update_irqs(dev);
|
||||||
update_legacy(dev, old_legacy_ctrl);
|
update_legacy(dev, old_legacy_ctrl);
|
||||||
break;
|
break;
|
||||||
@@ -1239,17 +1236,17 @@ update_legacy(es1371_t *dev, uint32_t old_legacy_ctrl)
|
|||||||
if (old_legacy_ctrl & LEGACY_CAPTURE_CODEC) {
|
if (old_legacy_ctrl & LEGACY_CAPTURE_CODEC) {
|
||||||
switch ((old_legacy_ctrl >> LEGACY_CODEC_ADDR_SHIFT) & 3) {
|
switch ((old_legacy_ctrl >> LEGACY_CODEC_ADDR_SHIFT) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
io_removehandler(0x5300, 0x0080,
|
io_removehandler(0x0530, 0x0008,
|
||||||
capture_read_codec, NULL, NULL,
|
capture_read_codec, NULL, NULL,
|
||||||
capture_write_codec, NULL, NULL, dev);
|
capture_write_codec, NULL, NULL, dev);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
io_removehandler(0xe800, 0x0080,
|
io_removehandler(0x0e80, 0x0008,
|
||||||
capture_read_codec, NULL, NULL,
|
capture_read_codec, NULL, NULL,
|
||||||
capture_write_codec,NULL,NULL, dev);
|
capture_write_codec,NULL,NULL, dev);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
io_removehandler(0xf400, 0x0080,
|
io_removehandler(0x0f40, 0x0008,
|
||||||
capture_read_codec, NULL, NULL,
|
capture_read_codec, NULL, NULL,
|
||||||
capture_write_codec, NULL, NULL, dev);
|
capture_write_codec, NULL, NULL, dev);
|
||||||
break;
|
break;
|
||||||
@@ -1326,17 +1323,17 @@ update_legacy(es1371_t *dev, uint32_t old_legacy_ctrl)
|
|||||||
if (dev->legacy_ctrl & LEGACY_CAPTURE_CODEC) {
|
if (dev->legacy_ctrl & LEGACY_CAPTURE_CODEC) {
|
||||||
switch ((dev->legacy_ctrl >> LEGACY_CODEC_ADDR_SHIFT) & 3) {
|
switch ((dev->legacy_ctrl >> LEGACY_CODEC_ADDR_SHIFT) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
io_sethandler(0x5300, 0x0080,
|
io_sethandler(0x0530, 0x0008,
|
||||||
capture_read_codec, NULL, NULL,
|
capture_read_codec, NULL, NULL,
|
||||||
capture_write_codec, NULL, NULL, dev);
|
capture_write_codec, NULL, NULL, dev);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
io_sethandler(0xe800, 0x0080,
|
io_sethandler(0x0e80, 0x0008,
|
||||||
capture_read_codec, NULL, NULL,
|
capture_read_codec, NULL, NULL,
|
||||||
capture_write_codec, NULL, NULL, dev);
|
capture_write_codec, NULL, NULL, dev);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
io_sethandler(0xf400, 0x0080,
|
io_sethandler(0x0f40, 0x0008,
|
||||||
capture_read_codec, NULL, NULL,
|
capture_read_codec, NULL, NULL,
|
||||||
capture_write_codec, NULL, NULL, dev);
|
capture_write_codec, NULL, NULL, dev);
|
||||||
break;
|
break;
|
||||||
|
214
src/thread.c
214
src/thread.c
@@ -1,52 +1,191 @@
|
|||||||
#include <stdlib.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#ifdef __APPLE__
|
||||||
#include <inttypes.h>
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#include <86box/86box.h>
|
#include <86box/86box.h>
|
||||||
#include <86box/plat.h>
|
#include <86box/plat.h>
|
||||||
|
#if (defined WIN32) || (defined _WIN32) || (defined _WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
#include <process.h>
|
||||||
|
|
||||||
|
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 <pthread.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct event_pthread_t
|
typedef struct event_pthread_t
|
||||||
{
|
{
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
int state;
|
int state;
|
||||||
} event_pthread_t;
|
} event_pthread_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct thread_param
|
|
||||||
{
|
|
||||||
void (*thread_rout)(void*);
|
|
||||||
void * param;
|
|
||||||
} thread_param;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct pt_mutex_t
|
typedef struct pt_mutex_t
|
||||||
{
|
{
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
} pt_mutex_t;
|
} 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_t *
|
||||||
thread_create(void (*thread_rout)(void *param), void *param)
|
thread_create(void (*thread_rout)(void *param), void *param)
|
||||||
{
|
{
|
||||||
pthread_t *thread = malloc(sizeof(pthread_t));
|
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;
|
return thread;
|
||||||
}
|
}
|
||||||
@@ -101,10 +240,13 @@ thread_wait_event(event_t *handle, int timeout)
|
|||||||
event_pthread_t *event = (event_pthread_t *)handle;
|
event_pthread_t *event = (event_pthread_t *)handle;
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
|
|
||||||
#ifdef HAS_TIMESPEC_GET
|
#ifdef __linux__
|
||||||
timespec_get(&abstime, TIME_UTC);
|
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
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
|
#endif
|
||||||
abstime.tv_nsec += (timeout % 1000) * 1000000;
|
abstime.tv_nsec += (timeout % 1000) * 1000000;
|
||||||
abstime.tv_sec += (timeout / 1000);
|
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)
|
thread_wait_mutex(mutex_t *_mutex)
|
||||||
{
|
{
|
||||||
if (_mutex == NULL)
|
|
||||||
return(0);
|
|
||||||
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
||||||
|
|
||||||
return
|
pthread_mutex_lock(&mutex->mutex);
|
||||||
pthread_mutex_lock(&mutex->mutex) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
thread_release_mutex(mutex_t *_mutex)
|
thread_unlock_mutex(mutex_t *_mutex)
|
||||||
{
|
{
|
||||||
if (_mutex == NULL)
|
|
||||||
return(0);
|
|
||||||
pt_mutex_t *mutex = (pt_mutex_t *)_mutex;
|
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);
|
free(mutex);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@@ -1051,7 +1051,7 @@ plat_setfullscreen(int on)
|
|||||||
if ((!!(on & 1)) == (!!video_fullscreen))
|
if ((!!(on & 1)) == (!!video_fullscreen))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (on && (start_in_fullscreen || video_fullscreen_first)) {
|
if (on && video_fullscreen_first) {
|
||||||
video_fullscreen |= 2;
|
video_fullscreen |= 2;
|
||||||
if (ui_msgbox_header(MBX_INFO | MBX_DONTASK, (wchar_t *) IDS_2134, (wchar_t *) IDS_2052) == 10) {
|
if (ui_msgbox_header(MBX_INFO | MBX_DONTASK, (wchar_t *) IDS_2134, (wchar_t *) IDS_2052) == 10) {
|
||||||
video_fullscreen_first = 0;
|
video_fullscreen_first = 0;
|
||||||
|
@@ -1427,7 +1427,7 @@ ui_init(int nCmdShow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the mouse module. */
|
/* Initialize the mouse module. */
|
||||||
if (!start_in_fullscreen && !video_fullscreen_first)
|
if (!start_in_fullscreen)
|
||||||
win_mouse_init();
|
win_mouse_init();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1459,7 +1459,7 @@ ui_init(int nCmdShow)
|
|||||||
plat_resize(scrnsz_x, scrnsz_y);
|
plat_resize(scrnsz_x, scrnsz_y);
|
||||||
|
|
||||||
/* Initialize the rendering window, or fullscreen. */
|
/* Initialize the rendering window, or fullscreen. */
|
||||||
if (start_in_fullscreen || video_fullscreen_first)
|
if (start_in_fullscreen)
|
||||||
plat_setfullscreen(3);
|
plat_setfullscreen(3);
|
||||||
|
|
||||||
/* Fire up the machine. */
|
/* Fire up the machine. */
|
||||||
|
Reference in New Issue
Block a user