win32: call os_DoEvents on the emu/main thread and other fixes

This commit is contained in:
flyinghead 2019-02-07 19:20:10 +01:00
parent 82f156f143
commit 3cdd39170d
7 changed files with 25 additions and 17 deletions

View File

@ -396,7 +396,9 @@ void _vmem_term()
u8* virt_ram_base;
void* malloc_pages(size_t size) {
#ifdef _ISOC11_SOURCE
#if HOST_OS == OS_WINDOWS
return _aligned_malloc(size, PAGE_SIZE);
#elif defined(_ISOC11_SOURCE)
return aligned_alloc(PAGE_SIZE, size);
#else
void *data;
@ -794,10 +796,16 @@ void _vmem_release()
{
if (virt_ram_base != NULL)
{
#if HOST_OS == OS_WINDOWS
VirtualFree(virt_ram_base, 0, MEM_RELEASE);
#else
munmap(virt_ram_base, 0x20000000);
#endif
virt_ram_base = NULL;
}
#if HOST_OS != OS_WINDOWS
close(fd);
#endif
}
}

View File

@ -53,7 +53,7 @@
extern u32* emit_ptr;
extern u8* CodeCache;
#if HOST_OS==OS_LINUX || HOST_OS==OS_DARWIN
#ifdef __cplusplus
extern "C" {
#endif
@ -116,6 +116,6 @@ void ngen_CC_Finish(shil_opcode* op);
RuntimeBlockInfo* ngen_AllocateBlock();
#if HOST_OS==OS_LINUX || HOST_OS==OS_DARWIN
#ifdef __cplusplus
}
#endif

View File

@ -27,8 +27,8 @@ void dc_resume_emu(bool continue_running);
settings_t settings;
static bool continue_running = false;
static cMutex mtx_serialization ;
static cMutex mtx_mainloop ;
static cResetEvent resume_mainloop(false, true);
/*
libndc
@ -426,6 +426,8 @@ bool dc_is_running()
#ifndef TARGET_DISPFRAME
void dc_run()
{
resume_mainloop.Set();
while ( true )
{
bool dynarec_enabled = settings.dynarec.Enable;
@ -434,8 +436,8 @@ void dc_run()
sh4_cpu.Run();
mtx_mainloop.Unlock() ;
mtx_serialization.Lock() ;
mtx_serialization.Unlock() ;
while (!resume_mainloop.Wait(20))
os_DoEvents();
if (dynarec_enabled != settings.dynarec.Enable)
{
@ -697,10 +699,10 @@ bool dc_pause_emu()
if (sh4_cpu.IsCpuRunning())
{
#ifndef TARGET_NO_THREADS
mtx_serialization.Lock();
resume_mainloop.Reset();
if (!wait_until_dc_running()) {
printf("Can't open settings - dc loop kept running\n");
mtx_serialization.Unlock();
resume_mainloop.Set();
return false;
}
@ -710,7 +712,7 @@ bool dc_pause_emu()
{
printf("Can't open settings - could not acquire main loop lock\n");
continue_running = true;
mtx_serialization.Unlock();
resume_mainloop.Set();
return false;
}
#else
@ -726,7 +728,7 @@ void dc_resume_emu(bool continue_running)
{
::continue_running = continue_running;
rend_cancel_emu_wait();
mtx_serialization.Unlock();
resume_mainloop.Set();
mtx_mainloop.Unlock();
}
}

View File

@ -37,7 +37,7 @@ void DetectCpuFeatures()
if (detected) return;
detected=true;
#if HOST_OS==OS_WINDOWS
#ifdef _MSC_VER
__try
{
__asm addps xmm0,xmm0
@ -84,7 +84,7 @@ void DetectCpuFeatures()
{
mmx=false;
}
#endif
#endif
}

View File

@ -130,7 +130,6 @@ static void ImGui_Impl_NewFrame()
ImGuiIO& io = ImGui::GetIO();
os_DoEvents();
UpdateInputState(0);
// Read keyboard modifiers inputs

View File

@ -305,7 +305,6 @@ public:
}
};
int ExeptionHandler(u32 dwCode, void* pExceptionPointers);
int msgboxf(const wchar* text,unsigned int type,...);

View File

@ -235,19 +235,19 @@ else ifneq (,$(findstring vero4k,$(platform)))
# Windows
else ifneq (,$(findstring win32,$(platform)))
X64_REC := 1
NOT_ARM := 1
CFLAGS += -DTARGET_NO_WEBUI -fno-builtin-sqrtf -funroll-loops -DHAVE_FSEEKO
CFLAGS += -DTARGET_NO_WEBUI -fno-builtin-sqrtf -funroll-loops -DHAVE_FSEEKO -D TARGET_NO_AREC
LDFLAGS += -static-libgcc -static-libstdc++
LIBS := -lopengl32 -lwinmm -lgdi32 -lwsock32 -ldsound -lcomctl32 -lcomdlg32 -lxinput -liphlpapi
PLATFORM_EXT := exe
CC = gcc
CXX = g++
ifeq ($(WITH_DYNAREC), x86)
X86_REC := 1
LDFLAGS += -m32
CFLAGS += -m32
else
CFLAGS += -D TARGET_NO_AREC
X64_REC := 1
endif
undefine USE_X11
undefine USE_ALSA