From 16a8c4cb2582d55c68435ebab7077a381800ed5c Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 16 Oct 2021 00:14:26 +0600 Subject: [PATCH 1/4] Add more missing strings to Unix backend --- src/unix/unix.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/unix/unix.c b/src/unix/unix.c index 8db22f39a..0dc966802 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -249,6 +249,12 @@ wchar_t* plat_get_string(int i) return L"Make sure libpcap is installed and that you are on a libpcap-compatible network connection."; case IDS_2114: return L"Unable to initialize Ghostscript"; + case IDS_2063: + return L"Machine \"%hs\" is not available due to missing ROMs in the roms/machines directory. Switching to an available machine."; + case IDS_2064: + return L"Video card \"%hs\" is not available due to missing ROMs in the roms/video directory. Switching to an available video card."; + case IDS_2128: + return L"Hardware not available"; } return L""; } From 33de2779008a13bbeb840c6620bacf2ace19892f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= <84271678+laciba96@users.noreply.github.com> Date: Sat, 16 Oct 2021 18:18:34 +0200 Subject: [PATCH 2/4] Fixing the main window's icon in the title bar --- src/win/win_ui.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 9b1f64d5d..a099489aa 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -1304,13 +1304,19 @@ ui_init(int nCmdShow) wincl.lpfnWndProc = MainWindowProcedure; wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof(WNDCLASSEX); - wincl.hIcon = LoadIcon(hinstance, (LPCTSTR)10); - wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR)10); + wincl.hIcon = NULL; + wincl.hIconSm = NULL; wincl.hCursor = NULL; wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hbrBackground = CreateSolidBrush(RGB(0,0,0)); + + /* Load proper icons */ + wchar_t path[MAX_PATH + 1] = {0}; + GetModuleFileNameW(hinstance, path, MAX_PATH); + ExtractIconExW(path, 0, &wincl.hIcon, &wincl.hIconSm, 1); + if (! RegisterClassEx(&wincl)) return(2); wincl.lpszClassName = SUB_CLASS_NAME; From 8b5e39ceed7d887071a6f46c8c687cc3f5045751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= <84271678+laciba96@users.noreply.github.com> Date: Sat, 16 Oct 2021 18:38:32 +0200 Subject: [PATCH 3/4] Merge dynarec fixes from Cacodemon345's branch Get rid of mprotect call entirely on x64 dynamic recompiler Use mmap whenever possible on old dynamic recompiler --- src/codegen/codegen_x86-64.c | 21 +++------------------ src/codegen/codegen_x86.c | 8 +++++--- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/codegen/codegen_x86-64.c b/src/codegen/codegen_x86-64.c index e3e6ced89..289411b37 100644 --- a/src/codegen/codegen_x86-64.c +++ b/src/codegen/codegen_x86-64.c @@ -21,7 +21,7 @@ #include "codegen_ops.h" #include "codegen_ops_x86-64.h" -#if defined(__linux__) || defined(__APPLE__) +#if defined(__unix__) || defined(__APPLE__) #include #include #endif @@ -63,16 +63,11 @@ static int last_ssegs; void codegen_init() { int c; - -#if defined(__linux__) || defined(__APPLE__) - void *start; - size_t len; - long pagesize = sysconf(_SC_PAGESIZE); - long pagemask = ~(pagesize - 1); -#endif #if _WIN64 codeblock = VirtualAlloc(NULL, BLOCK_SIZE * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE); +#elif defined(__unix__) || defined(__APPLE__) + codeblock = mmap(NULL, BLOCK_SIZE * sizeof(codeblock_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, 0, 0); #else codeblock = malloc(BLOCK_SIZE * sizeof(codeblock_t)); #endif @@ -83,16 +78,6 @@ void codegen_init() for (c = 0; c < BLOCK_SIZE; c++) codeblock[c].valid = 0; - -#if defined(__linux__) || defined(__APPLE__) - start = (void *)((long)codeblock & pagemask); - len = ((BLOCK_SIZE * sizeof(codeblock_t)) + pagesize) & pagemask; - if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) - { - perror("mprotect"); - exit(-1); - } -#endif } void codegen_reset() diff --git a/src/codegen/codegen_x86.c b/src/codegen/codegen_x86.c index beb245963..f0b5169d4 100644 --- a/src/codegen/codegen_x86.c +++ b/src/codegen/codegen_x86.c @@ -61,7 +61,7 @@ #include "codegen_ops.h" #include "codegen_ops_x86.h" -#ifdef __linux__ +#ifdef __unix__ #include #include #endif @@ -1173,7 +1173,7 @@ static uint32_t gen_MEM_CHECK_WRITE_L() void codegen_init() { -#ifdef __linux__ +#ifdef __unix__ void *start; size_t len; long pagesize = sysconf(_SC_PAGESIZE); @@ -1182,6 +1182,8 @@ void codegen_init() #ifdef _WIN32 codeblock = VirtualAlloc(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE); +#elif defined __unix__ + codeblock = mmap(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, 0, 0); #else codeblock = malloc((BLOCK_SIZE+1) * sizeof(codeblock_t)); #endif @@ -1190,7 +1192,7 @@ void codegen_init() memset(codeblock, 0, (BLOCK_SIZE+1) * sizeof(codeblock_t)); memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); -#ifdef __linux__ +#ifdef __unix__ start = (void *)((long)codeblock & pagemask); len = (((BLOCK_SIZE+1) * sizeof(codeblock_t)) + pagesize) & pagemask; if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) From 17f7fa343721d9a0766d0c3e20835fa990899db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= <84271678+laciba96@users.noreply.github.com> Date: Sat, 16 Oct 2021 19:43:50 +0200 Subject: [PATCH 4/4] Merge further fixes to the 32-bit recompiler Remove mprotect usages in 32-bit x86 dynamic recompiler --- src/codegen/codegen_x86.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/codegen/codegen_x86.c b/src/codegen/codegen_x86.c index f0b5169d4..b4ba9bc9f 100644 --- a/src/codegen/codegen_x86.c +++ b/src/codegen/codegen_x86.c @@ -1173,17 +1173,10 @@ static uint32_t gen_MEM_CHECK_WRITE_L() void codegen_init() { -#ifdef __unix__ - void *start; - size_t len; - long pagesize = sysconf(_SC_PAGESIZE); - long pagemask = ~(pagesize - 1); -#endif - #ifdef _WIN32 codeblock = VirtualAlloc(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), MEM_COMMIT, PAGE_EXECUTE_READWRITE); #elif defined __unix__ - codeblock = mmap(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, 0, 0); + codeblock = mmap(NULL, (BLOCK_SIZE+1) * sizeof(codeblock_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, 0, 0); #else codeblock = malloc((BLOCK_SIZE+1) * sizeof(codeblock_t)); #endif @@ -1192,16 +1185,6 @@ void codegen_init() memset(codeblock, 0, (BLOCK_SIZE+1) * sizeof(codeblock_t)); memset(codeblock_hash, 0, HASH_SIZE * sizeof(codeblock_t *)); -#ifdef __unix__ - start = (void *)((long)codeblock & pagemask); - len = (((BLOCK_SIZE+1) * sizeof(codeblock_t)) + pagesize) & pagemask; - if (mprotect(start, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) - { - perror("mprotect"); - exit(-1); - } -#endif - block_current = BLOCK_SIZE; block_pos = 0; mem_abrt_rout = (uint32_t)&codeblock[block_current].data[block_pos];