From 0e198fac5802f1f40e050cddf2af49af84c3ced3 Mon Sep 17 00:00:00 2001 From: flyinghead Date: Sat, 30 Mar 2019 11:22:51 +0100 Subject: [PATCH 01/73] win32: allow window to be resized/maximized. Save size and max state. --- core/windows/winmain.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index d8d0e19df..480367f56 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -232,9 +232,10 @@ void UpdateInputState(u32 port) #define WINDOW_CLASS "nilDC" // Width and height of the window -#define WINDOW_WIDTH 1280 -#define WINDOW_HEIGHT 720 - +#define DEFAULT_WINDOW_WIDTH 1280 +#define DEFAULT_WINDOW_HEIGHT 720 +extern int screen_width, screen_height; +static bool window_maximized = false; LRESULT CALLBACK WndProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -259,6 +260,12 @@ LRESULT CALLBACK WndProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) PostQuitMessage(0); return 1; + case WM_SIZE: + screen_width = LOWORD(lParam); + screen_height = HIWORD(lParam); + window_maximized = (wParam & SIZE_MAXIMIZED) != 0; + return 0; + case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONDOWN: @@ -293,8 +300,8 @@ LRESULT CALLBACK WndProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static int prev_y = -1; int xPos = GET_X_LPARAM(lParam); int yPos = GET_Y_LPARAM(lParam); - mo_x_abs = (xPos - (WINDOW_WIDTH - 640 * WINDOW_HEIGHT / 480) / 2) * 480 / WINDOW_HEIGHT; - mo_y_abs = yPos * 480 / WINDOW_HEIGHT; + mo_x_abs = (xPos - (screen_width - 640 * screen_height / 480) / 2) * 480 / screen_height; + mo_y_abs = yPos * 480 / screen_height; mo_buttons = 0xffffffff; if (wParam & MK_LBUTTON) mo_buttons &= ~(1 << 2); @@ -354,12 +361,13 @@ void os_CreateWindow() sWC.cbWndExtra = 0; sWC.hInstance = (HINSTANCE)GetModuleHandle(0); sWC.hIcon = 0; - sWC.hCursor = 0; + sWC.hCursor = LoadCursor(NULL, IDC_ARROW); sWC.lpszMenuName = 0; sWC.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); sWC.lpszClassName = WINDOW_CLASS; - unsigned int nWidth = WINDOW_WIDTH; - unsigned int nHeight = WINDOW_HEIGHT; + screen_width = cfgLoadInt("windows", "width", DEFAULT_WINDOW_WIDTH); + screen_height = cfgLoadInt("windows", "height", DEFAULT_WINDOW_HEIGHT); + window_maximized = cfgLoadBool("windows", "maximized", false); ATOM registerClass = RegisterClass(&sWC); if (!registerClass) @@ -369,9 +377,10 @@ void os_CreateWindow() // Create the eglWindow RECT sRect; - SetRect(&sRect, 0, 0, nWidth, nHeight); - AdjustWindowRectEx(&sRect, WS_CAPTION | WS_SYSMENU, false, 0); - HWND hWnd = CreateWindow( WINDOW_CLASS, VER_FULLNAME, WS_VISIBLE | WS_SYSMENU, + SetRect(&sRect, 0, 0, screen_width, screen_height); + AdjustWindowRectEx(&sRect, WS_OVERLAPPEDWINDOW, false, 0); + + HWND hWnd = CreateWindow( WINDOW_CLASS, VER_FULLNAME, WS_VISIBLE | WS_OVERLAPPEDWINDOW | (window_maximized ? WS_MAXIMIZE : 0), 0, 0, sRect.right-sRect.left, sRect.bottom-sRect.top, NULL, NULL, sWC.hInstance, NULL); window_win=hWnd; @@ -685,6 +694,12 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine } #endif SetUnhandledExceptionFilter(0); + cfgSaveBool("windows", "maximized", window_maximized); + if (!window_maximized) + { + cfgSaveInt("windows", "width", screen_width); + cfgSaveInt("windows", "height", screen_height); + } return 0; } From 4b0e77a2b3805c5921f618ab8f053f9538bb0d77 Mon Sep 17 00:00:00 2001 From: flyinghead Date: Sat, 30 Mar 2019 11:27:14 +0100 Subject: [PATCH 02/73] win32: don't save window size if minimized --- core/windows/winmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 480367f56..1731193e9 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -695,7 +695,7 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine #endif SetUnhandledExceptionFilter(0); cfgSaveBool("windows", "maximized", window_maximized); - if (!window_maximized) + if (!window_maximized && screen_width != 0 && screen_width != 0) { cfgSaveInt("windows", "width", screen_width); cfgSaveInt("windows", "height", screen_height); From c02a6969df4427f9295c7c3f38d27c196bd78ee1 Mon Sep 17 00:00:00 2001 From: flyinghead Date: Sat, 30 Mar 2019 12:32:37 +0100 Subject: [PATCH 03/73] win32: add app icon and version resource --- core/.gitignore | 1 + core/core.mk | 11 +++-- core/rend/gui.cpp | 8 ++-- core/version/.gitignore | 1 - core/version/version.h | 3 -- .../reicast-osx.xcodeproj/project.pbxproj | 2 +- shell/linux/Makefile | 8 +++- shell/windows/reicast.ico | Bin 0 -> 103422 bytes shell/windows/reicast.rc | 39 ++++++++++++++++++ shell/windows/resource.h | 16 +++++++ 10 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 core/.gitignore delete mode 100644 core/version/.gitignore delete mode 100644 core/version/version.h create mode 100644 shell/windows/reicast.ico create mode 100644 shell/windows/reicast.rc create mode 100644 shell/windows/resource.h diff --git a/core/.gitignore b/core/.gitignore new file mode 100644 index 000000000..a948ed453 --- /dev/null +++ b/core/.gitignore @@ -0,0 +1 @@ +/version.h diff --git a/core/core.mk b/core/core.mk index cad01b997..1337c531a 100755 --- a/core/core.mk +++ b/core/core.mk @@ -5,7 +5,7 @@ #LDFLAGS := -Wl,-Map,$(notdir $@).map,--gc-sections -Wl,-O3 -Wl,--sort-common RZDCY_SRC_DIR ?= $(call my-dir) -VERSION_SRC := $(RZDCY_SRC_DIR)/version/version.cpp +VERSION_HEADER := $(RZDCY_SRC_DIR)/version.h RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ hw/modem/ \ hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/interpr/ hw/sh4/modules/ plugins/ profiler/ oslib/ \ @@ -94,7 +94,6 @@ RZDCY_FILES := $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(w RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cc)) RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.c)) RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.S)) -RZDCY_FILES += $(VERSION_SRC) ifdef FOR_PANDORA RZDCY_CFLAGS := \ @@ -156,8 +155,8 @@ endif RZDCY_CXXFLAGS := $(RZDCY_CFLAGS) -fno-exceptions -fno-rtti -std=gnu++11 -$(VERSION_SRC): - echo "const char *version = \"`git describe --tags --always`\";" > $(VERSION_SRC) - echo "const char *git_hash = \"`git rev-parse --short HEAD`\";" >> $(VERSION_SRC) - echo "const char *build_date = \"`date '+%Y-%m-%d %H:%M:%S %Z'`\";" >> $(VERSION_SRC) +$(VERSION_HEADER): + echo "#define REICAST_VERSION \"`git describe --tags --always`\"" > $(VERSION_HEADER) + echo "#define GIT_HASH \"`git rev-parse --short HEAD`\"" >> $(VERSION_HEADER) + echo "#define BUILD_DATE \"`date '+%Y-%m-%d %H:%M:%S %Z'`\"" >> $(VERSION_HEADER) diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 4b53795fb..54786facf 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -34,7 +34,7 @@ #include "linux-dist/main.h" // FIXME for kcode[] #include "gui_util.h" #include "gui_android.h" -#include "version/version.h" +#include "version.h" extern void dc_loadstate(); extern void dc_savestate(); @@ -1041,9 +1041,9 @@ static void gui_display_settings() ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding); if (ImGui::CollapsingHeader("Reicast", ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::Text("Version: %s", version); - ImGui::Text("Git Hash: %s", git_hash); - ImGui::Text("Build Date: %s", build_date); + ImGui::Text("Version: %s", REICAST_VERSION); + ImGui::Text("Git Hash: %s", GIT_HASH); + ImGui::Text("Build Date: %s", BUILD_DATE); ImGui::Text("Target: %s", #if DC_PLATFORM == DC_PLATFORM_DREAMCAST "Dreamcast" diff --git a/core/version/.gitignore b/core/version/.gitignore deleted file mode 100644 index 1946cee8c..000000000 --- a/core/version/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/version.cpp diff --git a/core/version/version.h b/core/version/version.h deleted file mode 100644 index 3c9912aa7..000000000 --- a/core/version/version.h +++ /dev/null @@ -1,3 +0,0 @@ -extern const char *version; -extern const char *git_hash; -extern const char *build_date; diff --git a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj index b50789eb9..a12ad753f 100644 --- a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj +++ b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj @@ -2199,7 +2199,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"const char *version = \\\"`git describe --tags --always`\\\";\" > $SRCROOT/../../../core/version/version.cpp\necho \"const char *git_hash = \\\"`git rev-parse --short HEAD`\\\";\" >> $SRCROOT/../../../core/version/version.cpp\necho \"const char *build_date = \\\"`date '+%Y-%m-%d %H:%M:%S %Z'`\\\";\" >> $SRCROOT/../../../core/version/version.cpp\n"; + shellScript = "echo \"#define REICAST_VERSION \\\"`git describe --tags --always`\\\"\" > $SRCROOT/../../../core/version.h\necho \"#define GIT_HASH \\\"`git rev-parse --short HEAD`\\\"\" >> $SRCROOT/../../../core/version.h\necho \"#define BUILD_DATE \\\"`date '+%Y-%m-%d %H:%M:%S %Z'`\\\"\" >> $SRCROOT/../../../core/version.h\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/shell/linux/Makefile b/shell/linux/Makefile index eea87ef76..aa2acba74 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -421,6 +421,12 @@ OBJECTS:=$(OBJECTS:.c=.build_obj) OBJECTS:=$(OBJECTS:.S=.build_obj) OBJECTS:=$(patsubst $(RZDCY_SRC_DIR)/%,$(BUILDDIR)/%,$(OBJECTS)) +ifdef FOR_WINDOWS +OBJECTS+=$(BUILDDIR)/reicastres.build_obj +$(BUILDDIR)/reicastres.build_obj: $(LOCAL_PATH)/../windows/reicast.rc $(LOCAL_PATH)/../windows/reicast.ico $(RZDCY_SRC_DIR)/version.h + windres $< $@ +endif + DEPDIR := .dep-$(BUILDDIR) DEPFLAGS = -MT $@ -MD -MP -MF $(DEPDIR)/$*.Td DEPS=$(RZDCY_FILES:.cpp=.d) @@ -500,7 +506,7 @@ uninstall: rm -f $(DESTDIR)$(ICON_DIR)/reicast.png clean: - rm -f $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE_STRIPPED) .map + rm -f $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE_STRIPPED) .map $(RZDCY_SRC_DIR)/version.h .PRECIOUS = $(DEPDIR)/%.d $(DEPDIR)/%.d: ; diff --git a/shell/windows/reicast.ico b/shell/windows/reicast.ico new file mode 100644 index 0000000000000000000000000000000000000000..99528ed33a1e76c635b124bf67983ba16b478049 GIT binary patch literal 103422 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 Date: Sat, 30 Mar 2019 13:40:36 +0100 Subject: [PATCH 04/73] linux and android build fix --- shell/android-studio/reicast/src/main/jni/Android.mk | 2 ++ shell/linux/Makefile | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/shell/android-studio/reicast/src/main/jni/Android.mk b/shell/android-studio/reicast/src/main/jni/Android.mk index 357131a41..9bb894c11 100644 --- a/shell/android-studio/reicast/src/main/jni/Android.mk +++ b/shell/android-studio/reicast/src/main/jni/Android.mk @@ -112,6 +112,8 @@ else endif endif +$(LOCAL_SRC_FILES): $(VERSION_HEADER) + # # android has poor support for hardfp calling. # r9b+ is required, and it only works for internal calls diff --git a/shell/linux/Makefile b/shell/linux/Makefile index aa2acba74..306667515 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -448,27 +448,27 @@ $(EXECUTABLE_STRIPPED): $(EXECUTABLE) cp $< $@ && $(STRIP) $@ $(BUILDDIR)/%.build_obj : $(RZDCY_SRC_DIR)/%.cpp -$(BUILDDIR)/%.build_obj: $(RZDCY_SRC_DIR)/%.cpp $(DEPDIR)/%.d +$(BUILDDIR)/%.build_obj: $(RZDCY_SRC_DIR)/%.cpp $(DEPDIR)/%.d $(VERSION_HEADER) mkdir -p $(dir $@) mkdir -p .dep-$(dir $@) $(CXX) $(EXTRAFLAGS) $(INCS) $(DEPFLAGS) $(CFLAGS) $(MFLAGS) $(CXXFLAGS) $< -o $@ $(POSTCOMPILE) $(BUILDDIR)/%.build_obj : $(RZDCY_SRC_DIR)/%.cc -$(BUILDDIR)/%.build_obj: $(RZDCY_SRC_DIR)/%.cc $(DEPDIR)/%.d +$(BUILDDIR)/%.build_obj: $(RZDCY_SRC_DIR)/%.cc $(DEPDIR)/%.d $(VERSION_HEADER) mkdir -p $(dir $@) mkdir -p .dep-$(dir $@) $(CXX) $(EXTRAFLAGS) $(INCS) $(DEPFLAGS) $(CFLAGS) $(MFLAGS) $(CXXFLAGS) $< -o $@ $(POSTCOMPILE) $(BUILDDIR)/%.build_obj : $(RZDCY_SRC_DIR)/%.c -$(BUILDDIR)/%.build_obj: $(RZDCY_SRC_DIR)/%.c $(DEPDIR)/%.d +$(BUILDDIR)/%.build_obj: $(RZDCY_SRC_DIR)/%.c $(DEPDIR)/%.d $(VERSION_HEADER) mkdir -p $(dir $@) mkdir -p .dep-$(dir $@) $(CC) $(EXTRAFLAGS) $(INCS) $(DEPFLAGS) $(CFLAGS) $< -o $@ $(POSTCOMPILE) -$(BUILDDIR)/%.build_obj : $(RZDCY_SRC_DIR)/%.S +$(BUILDDIR)/%.build_obj : $(RZDCY_SRC_DIR)/%.S $(VERSION_HEADER) mkdir -p $(dir $@) $(AS) $(ASFLAGS) $(INCS) $< -o $@ @@ -506,7 +506,7 @@ uninstall: rm -f $(DESTDIR)$(ICON_DIR)/reicast.png clean: - rm -f $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE_STRIPPED) .map $(RZDCY_SRC_DIR)/version.h + rm -f $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE_STRIPPED) .map $(VERSION_HEADER) .PRECIOUS = $(DEPDIR)/%.d $(DEPDIR)/%.d: ; From 7f0489ff286fe3a176c1d6db76560f44f5f9250c Mon Sep 17 00:00:00 2001 From: flyinghead Date: Sat, 30 Mar 2019 19:26:05 +0100 Subject: [PATCH 05/73] visual studio compatibility no modem support no zip or 7z support so no naomi for now hacked a .asm file as vs doesn't support inline assembly -> code dup --- core/archive/archive.cpp | 4 + core/deps/dirent/dirent.c | 148 ++ core/deps/dirent/dirent.h | 50 + core/hw/naomi/awcartridge.cpp | 5 + core/hw/sh4/dyna/blockmanager.h | 5 +- core/hw/sh4/sh4_if.h | 2 +- core/hw/sh4/sh4_interpreter.h | 5 +- core/rec-x64/msvc.asm | 61 + core/rec-x64/rec_x64.cpp | 7 +- core/rend/gles/CustomTexture.cpp | 4 + core/rend/gui.cpp | 5 + core/rend/gui_util.cpp | 8 + core/stdclass.cpp | 12 +- core/windows/winmain.cpp | 33 +- core/windows/xinput_gamepad.h | 1 - shell/linux/Makefile | 4 +- shell/reicast.vcxproj | 145 +- shell/reicast.vcxproj.filters | 2627 ++++++++++++++++-------------- 18 files changed, 1870 insertions(+), 1256 deletions(-) create mode 100644 core/deps/dirent/dirent.c create mode 100644 core/deps/dirent/dirent.h create mode 100644 core/rec-x64/msvc.asm diff --git a/core/archive/archive.cpp b/core/archive/archive.cpp index 904839a5f..1bef0f2a4 100644 --- a/core/archive/archive.cpp +++ b/core/archive/archive.cpp @@ -21,12 +21,15 @@ #include "archive.h" #include "7zArchive.h" +#ifndef _MSC_VER #include "ZipArchive.h" +#endif Archive *OpenArchive(const char *path) { std::string base_path(path); +#ifndef _MSC_VER Archive *sz_archive = new SzArchive(); if (sz_archive->Open(base_path.c_str()) || sz_archive->Open((base_path + ".7z").c_str()) || sz_archive->Open((base_path + ".7Z").c_str())) return sz_archive; @@ -36,6 +39,7 @@ Archive *OpenArchive(const char *path) if (zip_archive->Open(base_path.c_str()) || zip_archive->Open((base_path + ".zip").c_str()) || zip_archive->Open((base_path + ".ZIP").c_str())) return zip_archive; delete zip_archive; +#endif return NULL; } diff --git a/core/deps/dirent/dirent.c b/core/deps/dirent/dirent.c new file mode 100644 index 000000000..8d496474c --- /dev/null +++ b/core/deps/dirent/dirent.c @@ -0,0 +1,148 @@ +/* + + Implementation of POSIX directory browsing functions and types for Win32. + + Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) + History: Created March 1997. Updated June 2003 and July 2012. + Rights: See end of file. + +*/ + +#include "dirent.h" +#include +#include /* _findfirst and _findnext set errno iff they return -1 */ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef ptrdiff_t handle_type; /* C99's intptr_t not sufficiently portable */ + + struct DIR + { + handle_type handle; /* -1 for failed rewind */ + struct _finddata_t info; + struct dirent result; /* d_name null iff first time */ + char *name; /* null-terminated char string */ + }; + + DIR *opendir(const char *name) + { + DIR *dir = 0; + + if (name && name[0]) + { + size_t base_length = strlen(name); + const char *all = /* search pattern must end with suitable wildcard */ + strchr("/\\", name[base_length - 1]) ? "*" : "/*"; + + if ((dir = (DIR *)malloc(sizeof *dir)) != 0 && + (dir->name = (char *)malloc(base_length + strlen(all) + 1)) != 0) + { + strcat(strcpy(dir->name, name), all); + + if ((dir->handle = + (handle_type)_findfirst(dir->name, &dir->info)) != -1) + { + dir->result.d_name = 0; + } + else /* rollback */ + { + free(dir->name); + free(dir); + dir = 0; + } + } + else /* rollback */ + { + free(dir); + dir = 0; + errno = ENOMEM; + } + } + else + { + errno = EINVAL; + } + + return dir; + } + + int closedir(DIR *dir) + { + int result = -1; + + if (dir) + { + if (dir->handle != -1) + { + result = _findclose(dir->handle); + } + + free(dir->name); + free(dir); + } + + if (result == -1) /* map all errors to EBADF */ + { + errno = EBADF; + } + + return result; + } + + struct dirent *readdir(DIR *dir) + { + struct dirent *result = 0; + + if (dir && dir->handle != -1) + { + if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) + { + result = &dir->result; + result->d_name = dir->info.name; + } + } + else + { + errno = EBADF; + } + + return result; + } + + void rewinddir(DIR *dir) + { + if (dir && dir->handle != -1) + { + _findclose(dir->handle); + dir->handle = (handle_type)_findfirst(dir->name, &dir->info); + dir->result.d_name = 0; + } + else + { + errno = EBADF; + } + } + +#ifdef __cplusplus +} +#endif + +/* + + Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved. + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose is hereby granted without fee, provided + that this copyright and permissions notice appear in all copies and + derivatives. + + This software is supplied "as is" without express or implied warranty. + + But that said, if there are any problems please get in touch. + +*/ diff --git a/core/deps/dirent/dirent.h b/core/deps/dirent/dirent.h new file mode 100644 index 000000000..192be112f --- /dev/null +++ b/core/deps/dirent/dirent.h @@ -0,0 +1,50 @@ +#ifndef DIRENT_INCLUDED +#define DIRENT_INCLUDED + +/* + + Declaration of POSIX directory browsing functions and types for Win32. + + Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) + History: Created March 1997. Updated June 2003. + Rights: See end of file. + +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct DIR DIR; + + struct dirent + { + char *d_name; + }; + + DIR *opendir(const char *); + int closedir(DIR *); + struct dirent *readdir(DIR *); + void rewinddir(DIR *); + + /* + + Copyright Kevlin Henney, 1997, 2003. All rights reserved. + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose is hereby granted without fee, provided + that this copyright and permissions notice appear in all copies and + derivatives. + + This software is supplied "as is" without express or implied warranty. + + But that said, if there are any problems please get in touch. + + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/core/hw/naomi/awcartridge.cpp b/core/hw/naomi/awcartridge.cpp index 02b773b1a..f013ce8f7 100644 --- a/core/hw/naomi/awcartridge.cpp +++ b/core/hw/naomi/awcartridge.cpp @@ -162,6 +162,11 @@ ROM board internal layouts: */ #include "awcartridge.h" #include "awave_regs.h" +#ifdef _MSC_VER +#undef min +#undef max +#include +#endif u32 AWCartridge::ReadMem(u32 address, u32 size) { verify(size != 1); diff --git a/core/hw/sh4/dyna/blockmanager.h b/core/hw/sh4/dyna/blockmanager.h index f676500c3..5c11af77f 100644 --- a/core/hw/sh4/dyna/blockmanager.h +++ b/core/hw/sh4/dyna/blockmanager.h @@ -86,7 +86,10 @@ void bm_WriteBlockMap(const string& file); DynarecCodeEntryPtr DYNACALL bm_GetCode(u32 addr); extern "C" { -__attribute__((used)) DynarecCodeEntryPtr DYNACALL bm_GetCode2(u32 addr); +#ifndef _MSC_VER +__attribute__((used)) +#endif + DynarecCodeEntryPtr DYNACALL bm_GetCode2(u32 addr); } RuntimeBlockInfo* bm_GetBlock(void* dynarec_code); diff --git a/core/hw/sh4/sh4_if.h b/core/hw/sh4/sh4_if.h index c9505700b..ddd295a1b 100644 --- a/core/hw/sh4/sh4_if.h +++ b/core/hw/sh4/sh4_if.h @@ -314,7 +314,7 @@ struct Sh4RCB Sh4Context cntx; }; -extern Sh4RCB* p_sh4rcb; +extern "C" Sh4RCB* p_sh4rcb; extern u8* sh4_dyna_rcb; INLINE u32 sh4_sr_GetFull() diff --git a/core/hw/sh4/sh4_interpreter.h b/core/hw/sh4/sh4_interpreter.h index 2bf603e76..8d827af84 100644 --- a/core/hw/sh4/sh4_interpreter.h +++ b/core/hw/sh4/sh4_interpreter.h @@ -61,6 +61,9 @@ void ExecuteDelayslot_RTE(); extern "C" { int UpdateSystem(); -__attribute__((used)) int UpdateSystem_INTC(); +#ifndef _MSC_VER +__attribute__((used)) +#endif + int UpdateSystem_INTC(); } diff --git a/core/rec-x64/msvc.asm b/core/rec-x64/msvc.asm new file mode 100644 index 000000000..4562cbdd2 --- /dev/null +++ b/core/rec-x64/msvc.asm @@ -0,0 +1,61 @@ +_TEXT SEGMENT + +SH4_TIMESLICE = 448 +CPU_RUNNING = 135266148 +PC = 135266120 + +EXTERN bm_GetCode2: PROC +EXTERN UpdateSystem_INTC: PROC +EXTERN cycle_counter: dword +EXTERN p_sh4rcb: qword + +PUBLIC ngen_mainloop +ngen_mainloop PROC + + push rbx + push rbp + push rdi + push rsi + push r12 + push r13 + push r14 + push r15 + sub rsp, 40 ; 32-byte shadow space + 8 for stack 16-byte alignment + + mov dword ptr [cycle_counter], SH4_TIMESLICE + +run_loop: + mov rax, qword ptr [p_sh4rcb] + mov edx, dword ptr[CPU_RUNNING + rax] + test edx, edx + je end_run_loop + +slice_loop: + mov rax, qword ptr [p_sh4rcb] + mov ecx, dword ptr[PC + rax] + call bm_GetCode2 + call rax + mov ecx, dword ptr [cycle_counter] + test ecx, ecx + jg slice_loop + + add ecx, SH4_TIMESLICE + mov dword ptr [cycle_counter], ecx + call UpdateSystem_INTC + jmp run_loop + +end_run_loop: + + add rsp, 40 + pop r15 + pop r14 + pop r13 + pop r12 + pop rsi + pop rdi + pop rbp + pop rbx + ret +ngen_mainloop ENDP +_TEXT ENDS +END diff --git a/core/rec-x64/rec_x64.cpp b/core/rec-x64/rec_x64.cpp index 19e9ba835..1f7a916fa 100644 --- a/core/rec-x64/rec_x64.cpp +++ b/core/rec-x64/rec_x64.cpp @@ -32,7 +32,9 @@ struct DynaRBI : RuntimeBlockInfo } }; -int cycle_counter; +extern "C" { + int cycle_counter; +} double host_cpu_time; u64 guest_cpu_cycles; @@ -76,6 +78,8 @@ static __attribute((used)) void end_slice() #error RAM_SIZE_MAX unknown #endif +#ifndef _MSC_VER + #ifdef _WIN32 // Fully naked function in win32 for proper SEH prologue __asm__ ( @@ -177,6 +181,7 @@ WIN32_ONLY( ".seh_pushreg %r14 \n\t") } #endif +#endif // !_MSC_VER #undef _U #undef _S diff --git a/core/rend/gles/CustomTexture.cpp b/core/rend/gles/CustomTexture.cpp index 3d8db4561..b384497f4 100644 --- a/core/rend/gles/CustomTexture.cpp +++ b/core/rend/gles/CustomTexture.cpp @@ -22,7 +22,11 @@ #include #include #include +#ifdef _MSC_VER +#include "dirent/dirent.h" +#else #include +#endif #include "deps/libpng/png.h" #include "reios/reios.h" diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 54786facf..7f59fd343 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -18,7 +18,12 @@ */ #include #include +#ifdef _MSC_VER +#include "dirent/dirent.h" +#define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR) +#else #include +#endif #include #include "gui.h" diff --git a/core/rend/gui_util.cpp b/core/rend/gui_util.cpp index f9e9ce91b..5fb9e9d02 100644 --- a/core/rend/gui_util.cpp +++ b/core/rend/gui_util.cpp @@ -21,8 +21,16 @@ #include #include #include +#ifdef _MSC_VER +#include +#include "dirent/dirent.h" +#define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR) +#define access _access +#define R_OK 4 +#else #include #include +#endif #include #include "types.h" diff --git a/core/stdclass.cpp b/core/stdclass.cpp index 5f689b72e..59bf1e94a 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -5,6 +5,10 @@ #include "types.h" #include "cfg/cfg.h" +#ifdef WIN32 +#include +#endif + #if BUILD_COMPILER==COMPILER_VC #include #define access _access @@ -140,11 +144,11 @@ string get_game_dir() bool make_directory(const string& path) { - return mkdir(path.c_str() -#ifndef _WIN32 - , 0755 +#ifdef WIN32 + return _mkdir(path.c_str()) == 0; +#else + return mkdir(path.c_str(), 0755) == 0; #endif - ) == 0; } #if 0 diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 1731193e9..0b1e38072 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -646,15 +646,31 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine int argc=0; wchar* cmd_line=GetCommandLineA(); wchar** argv=CommandLineToArgvA(cmd_line,&argc); - if(strstr(cmd_line,"NoConsole")==0) + for (int i = 0; i < argc; i++) { - if (AllocConsole()) + if (!stricmp(argv[i], "-console")) { - freopen("CON","w",stdout); - freopen("CON","w",stderr); - freopen("CON","r",stdin); + if (AllocConsole()) + { + freopen("CON", "w", stdout); + freopen("CON", "w", stderr); + freopen("CON", "r", stdin); + } + SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE); + } + else if (!stricmp(argv[i], "-log")) + { + const char *logfile; + if (i < argc - 1) + { + logfile = argv[i + 1]; + i++; + } + else + logfile = "reicast-log.txt"; + freopen(logfile, "w", stdout); + freopen(logfile, "w", stderr); } - SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ); } #endif @@ -662,14 +678,13 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine ReserveBottomMemory(); SetupPath(); -#ifndef __GNUC__ - __try -#else #ifdef _WIN64 AddVectoredExceptionHandler(1, ExeptionHandler); #else SetUnhandledExceptionFilter(&ExeptionHandler); #endif +#ifndef __GNUC__ + __try #endif { int reicast_init(int argc, char* argv[]); diff --git a/core/windows/xinput_gamepad.h b/core/windows/xinput_gamepad.h index 894d0aa79..336df20e4 100644 --- a/core/windows/xinput_gamepad.h +++ b/core/windows/xinput_gamepad.h @@ -181,7 +181,6 @@ protected: private: void do_rumble(float power) { - printf("do_rumble %f\n", power); XINPUT_VIBRATION vib; vib.wLeftMotorSpeed = (u16)(65535 * power); diff --git a/shell/linux/Makefile b/shell/linux/Makefile index 306667515..6af3aed05 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -240,7 +240,7 @@ else ifneq (,$(findstring vero4k,$(platform))) else ifneq (,$(findstring win32,$(platform))) NOT_ARM := 1 CFLAGS += -DTARGET_NO_WEBUI -fno-builtin-sqrtf -funroll-loops -DHAVE_FSEEKO -D TARGET_NO_AREC - LDFLAGS += -static-libgcc -static-libstdc++ + LDFLAGS += -static-libgcc -static-libstdc++ -Wl,-subsystem,windows LIBS := -lopengl32 -lwinmm -lgdi32 -lwsock32 -ldsound -lcomctl32 -lcomdlg32 -lxinput -liphlpapi PLATFORM_EXT := exe CC = gcc @@ -289,7 +289,7 @@ INCS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps -I$(RZDCY_SRC_DIR)/khronos LIBS += -lm -lpthread ifdef FOR_LINUX -LIBS += -lrt -ldl +LIBS += -lrt endif PREFIX ?= /usr/local diff --git a/shell/reicast.vcxproj b/shell/reicast.vcxproj index 6a8ec8b4c..2f10bff9e 100644 --- a/shell/reicast.vcxproj +++ b/shell/reicast.vcxproj @@ -35,6 +35,27 @@ + + true + true + true + true + true + true + true + true + + + + true + true + true + true + true + true + true + true + @@ -47,6 +68,7 @@ + @@ -68,6 +90,10 @@ + + + + @@ -154,6 +180,11 @@ + + + + + @@ -192,9 +223,13 @@ + + + + true true @@ -269,6 +304,8 @@ + + @@ -276,6 +313,9 @@ + + + @@ -284,6 +324,9 @@ + + + @@ -297,6 +340,7 @@ + @@ -313,6 +357,13 @@ + + + + + + + @@ -384,9 +435,17 @@ + + + + + + + + @@ -430,6 +489,10 @@ + + + + true true @@ -454,6 +517,11 @@ + + + + Document + true true @@ -464,9 +532,14 @@ + + + + + @@ -640,7 +713,7 @@ Level3 Full WIN32;CHD5_FLAC;PACKAGE_VERSION="1.3.2";FLAC__HAS_OGG=0;FLAC__NO_DLL;HAVE_LROUND;HAVE_STDINT_H;HAVE_STDLIB_H;CHD5_LZMA;_7ZIP_ST;NDEBUG;_CONSOLE;X86;RELEASE;%(PreprocessorDefinitions) - $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include + $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include /MP %(AdditionalOptions) AnySuitable true @@ -664,6 +737,13 @@ $(SolutionDir)..\pvrframe Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) + + for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" >$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('git rev-parse --short HEAD') do echo #define GIT_HASH "%%i" >>$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(ProjectDir)\..\core\version.h + + Create version.h + @@ -672,7 +752,7 @@ Level3 Full WIN32;CHD5_FLAC;PACKAGE_VERSION="1.3.2";FLAC__HAS_OGG=0;FLAC__NO_DLL;HAVE_LROUND;HAVE_STDINT_H;HAVE_STDLIB_H;CHD5_LZMA;_7ZIP_ST;NDEBUG;_CONSOLE;X86;RELEASE;TARGET_NAOMI;%(PreprocessorDefinitions) - $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include + $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include /MP %(AdditionalOptions) AnySuitable true @@ -696,6 +776,13 @@ $(SolutionDir)..\pvrframe Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) + + for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" >$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('git rev-parse --short HEAD') do echo #define GIT_HASH "%%i" >>$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(ProjectDir)\..\core\version.h + + Create version.h + @@ -704,7 +791,7 @@ Level3 Full WIN32;CHD5_FLAC;PACKAGE_VERSION="1.3.2";FLAC__HAS_OGG=0;FLAC__NO_DLL;HAVE_LROUND;HAVE_STDINT_H;HAVE_STDLIB_H;CHD5_LZMA;_7ZIP_ST;NDEBUG;_CONSOLE;X86;RELEASE;%(PreprocessorDefinitions) - $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include + $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include /MP %(AdditionalOptions) AnySuitable true @@ -730,6 +817,13 @@ $(SolutionDir)..\pvrframe Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) + + for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" >$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('git rev-parse --short HEAD') do echo #define GIT_HASH "%%i" >>$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(ProjectDir)\..\core\version.h + + Create version.h + @@ -738,7 +832,7 @@ Level3 Full WIN32;CHD5_FLAC;PACKAGE_VERSION="1.3.2";FLAC__HAS_OGG=0;FLAC__NO_DLL;HAVE_LROUND;HAVE_STDINT_H;HAVE_STDLIB_H;CHD5_LZMA;_7ZIP_ST;NDEBUG;_CONSOLE;X86;RELEASE;TARGET_NAOMI;%(PreprocessorDefinitions) - $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include + $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include /MP %(AdditionalOptions) AnySuitable true @@ -764,6 +858,13 @@ $(SolutionDir)..\pvrframe Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) + + for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" >$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('git rev-parse --short HEAD') do echo #define GIT_HASH "%%i" >>$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(ProjectDir)\..\core\version.h + + Create version.h + @@ -772,7 +873,7 @@ Level3 Disabled WIN32;CHD5_FLAC;PACKAGE_VERSION="1.3.2";FLAC__HAS_OGG=0;FLAC__NO_DLL;HAVE_LROUND;HAVE_STDINT_H;HAVE_STDLIB_H;CHD5_LZMA;_7ZIP_ST;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions) - $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include + $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include true false Default @@ -785,6 +886,13 @@ $(SolutionDir)..\pvrframe Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) + + for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" >$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('git rev-parse --short HEAD') do echo #define GIT_HASH "%%i" >>$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(ProjectDir)\..\core\version.h + + Create version.h + @@ -793,7 +901,7 @@ Level3 Disabled WIN32;CHD5_FLAC;PACKAGE_VERSION="1.3.2";FLAC__HAS_OGG=0;FLAC__NO_DLL;HAVE_LROUND;HAVE_STDINT_H;HAVE_STDLIB_H;CHD5_LZMA;_7ZIP_ST;_DEBUG;_CONSOLE;X86;TARGET_NAOMI;%(PreprocessorDefinitions) - $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include + $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include true false Default @@ -806,6 +914,13 @@ $(SolutionDir)..\pvrframe Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) + + for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" >$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('git rev-parse --short HEAD') do echo #define GIT_HASH "%%i" >>$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(ProjectDir)\..\core\version.h + + Create version.h + @@ -814,7 +929,7 @@ Level3 Disabled WIN32;CHD5_FLAC;PACKAGE_VERSION="1.3.2";FLAC__HAS_OGG=0;FLAC__NO_DLL;HAVE_LROUND;HAVE_STDINT_H;HAVE_STDLIB_H;CHD5_LZMA;_7ZIP_ST;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions) - $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include + $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include true false Default @@ -830,6 +945,13 @@ $(SolutionDir)..\pvrframe Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) + + for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" >$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('git rev-parse --short HEAD') do echo #define GIT_HASH "%%i" >>$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(ProjectDir)\..\core\version.h + + Create version.h + @@ -838,7 +960,7 @@ Level3 Disabled WIN32;CHD5_FLAC;PACKAGE_VERSION="1.3.2";FLAC__HAS_OGG=0;FLAC__NO_DLL;HAVE_LROUND;HAVE_STDINT_H;HAVE_STDLIB_H;CHD5_LZMA;_7ZIP_ST;_DEBUG;_CONSOLE;X86;TARGET_NAOMI;%(PreprocessorDefinitions) - $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include + $(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;$(ProjectDir)..\core\rend\gles;$(ProjectDir)..\core\deps;$(ProjectDir)..\core\deps\flac\src\libflac\include;$(ProjectDir)..\core\deps\flac\include true false Default @@ -854,6 +976,13 @@ $(SolutionDir)..\pvrframe Dsound.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) + + for /f "delims=" %%i in ('git describe') do echo #define REICAST_VERSION "%%i" >$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('git rev-parse --short HEAD') do echo #define GIT_HASH "%%i" >>$(ProjectDir)\..\core\version.h +for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(ProjectDir)\..\core\version.h + + Create version.h + diff --git a/shell/reicast.vcxproj.filters b/shell/reicast.vcxproj.filters index 6c854badf..1f347b584 100644 --- a/shell/reicast.vcxproj.filters +++ b/shell/reicast.vcxproj.filters @@ -1,1229 +1,1400 @@ - - - - - hw\aica - - - hw\aica - - - hw\aica - - - hw\aica - - - hw\aica - - - hw\arm7 - - - hw\arm7 - - - hw\arm7 - - - hw\arm7 - - - hw\gdrom - - - hw\gdrom - - - hw\maple - - - hw\maple - - - hw\maple - - - hw\maple - - - hw\mem - - - hw\sh4 - - - hw\pvr - - - hw\pvr - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\crypto - - - deps\crypto - - - imgread - - - imgread - - - imgread - - - imgread - - - imgread - - - imgread - - - - - cfg - - - cfg - - - emitter - - - windows - - - profiler - - - hw\holly - - - hw\holly - - - hw\holly - - - hw\sh4 - - - oslib - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\interpr - - - hw\sh4\interpr - - - hw\sh4\interpr - - - hw\sh4 - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4 - - - hw\sh4 - - - hw\sh4 - - - hw\sh4 - - - deps\libelf - - - deps\libelf - - - deps\libelf - - - linux - - - linux - - - deps\chdpsr - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - rend\gles - - - rend\gles - - - rend\gles - - - rend - - - rend\d3d11 - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - webui - - - deps\coreio - - - reios - - - reios - - - reios - - - reios - - - linux - - - oslib - - - rec-ARM - - - rec-x86 - - - rec-x86 - - - rec-x86 - - - rec-x64 - - - rec-cpp - - - rend\soft - - - hw\naomi - - - hw\naomi - - - cfg - - - - deps\xxhash - - - rend\gl4 - - - rend\gl4 - - - rend\gl4 - - - rend\gl4 - - - hw\aica - - - hw\modem - - - hw\modem - - - deps\xbrz - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\flac\src\libFLAC - - - deps\chdr - - - deps\chdr - - - deps\chdr - - - deps\chdr - - - deps\chdr - - - - - {2099cae6-67fb-489f-b082-7555e8330705} - - - {70620682-2709-4701-b0a7-7d8f8e1571de} - - - {9659b21d-ccee-4d2b-973d-09e447be743e} - - - {a07a09a2-a585-4144-a0d0-c54d4bb442ec} - - - {9da5f3a4-2e41-4f94-a499-e2524c4dd0c2} - - - {c3e9aa73-a90e-4f37-b357-b0378fb1feff} - - - {65dd7d80-739d-4b5c-a01c-3262cb8ec97a} - - - {da5bfaf9-fca7-4397-9034-e201c1f38e49} - - - {ee2a1c0f-d38c-4d2b-bb07-ba6841fc5832} - - - {09e0d071-e3c1-4549-b2a8-52f24f4691a8} - - - {d0252230-b46c-424f-8aa8-037774915f81} - - - {5cdde132-a201-4bbc-9dd4-2ba3b3637a19} - - - {bd80604a-c634-44b3-a729-811bbefd3f71} - - - {8783a652-88e4-49bf-be90-bc36abe6753b} - - - {2e4fe5a7-a86c-45cf-b456-39b107a91bc7} - - - {369d7f53-be71-4055-a303-675f1132b118} - - - {e14356dc-6635-49f9-94d5-dc14ff1dec70} - - - {f96b3c39-1255-4ee8-999e-5c6e8fef21e5} - - - {b81a858a-7327-4eb4-bc6b-6ae24e2c08fd} - - - {755fe7c9-b6b5-42e5-b0e6-d1d02d5a6e03} - - - {2bbf43fd-2127-412f-bd76-6260b04522f8} - - - {be756ece-25e8-4a69-b90e-2601fdbb42fe} - - - {66246039-9de4-4bc0-88a9-94582e2713e0} - - - {3ef102e4-a05f-4774-b2d7-7e1529bfd9b1} - - - {82948f1f-819b-4a2d-9e07-72dfbf3e96ca} - - - {fe073008-ffba-43c1-9192-daec4b48148e} - - - {fa363b78-585a-476a-9afc-628b0f6650cf} - - - {3f5c03ee-36db-4818-b0d2-4eec9c084f75} - - - {cd2c89fd-7a5b-43c8-a940-6ea0d29e9b5d} - - - {cc05f61b-c484-40e6-9859-6ca0cd64735c} - - - {3d3de3ff-9e79-4920-a95a-61d190e73004} - - - {81193efc-656a-4154-9adf-146856d4c7d3} - - - {23cfa286-fe88-439d-89de-a6a5a23cacc9} - - - {f614dd66-5d30-4548-a209-f857f95fb505} - - - {df854851-d3b5-4549-8248-acdfa954be44} - - - {5a7b63eb-8c03-46ac-b6e0-dfd3ade02f11} - - - {f73263e9-dbe8-4a6f-8b73-335af8307551} - - - {63d1fcf2-64b4-4973-995f-cd471f51117c} - - - {6c4b2d69-54c0-4660-9969-a98fd0339a15} - - - {1752487d-0739-47bf-8c6b-1d38e6f389f7} - - - {83d7e5cc-cbd2-40e3-b2c0-79cc53b1dd9a} - - - {e9e574e5-cce8-467b-8457-acf3999240c1} - - - {c1ffb17b-f29e-466a-a6a6-e93aa1bb2ca7} - - - {a67aece4-e47f-48a2-8944-6afbe679a5fb} - - - {4c0328b2-a9b3-4b0a-ab54-558ba960b03a} - - - {8bb0b4a0-7661-4533-9245-fc43582f6182} - - - {98226656-1e2d-4d69-bcd4-c1c1b6d4cb0a} - - - {f06382df-ae0e-459c-92a2-dc0eaab25b05} - - - {39e82b10-530a-4978-b8cc-8a11b67981d7} - - - {51e03f58-a90d-4ebc-95f7-6af6cdc39165} - - - {4c52c0a3-9e35-4285-a062-290d3667e1d1} - - - - - hw\aica - - - hw\aica - - - hw\aica - - - hw\aica - - - hw\aica - - - hw\arm7 - - - hw\arm7 - - - hw\arm7 - - - hw\arm7 - - - hw\gdrom - - - hw\gdrom - - - hw\maple - - - hw\maple - - - hw\maple - - - hw\maple - - - hw\mem - - - hw\sh4 - - - hw\sh4 - - - hw\sh4 - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\zlib - - - deps\crypto - - - deps\crypto - - - deps\chdr - - - deps\chdr - - - imgread - - - imgread - - - imgread - - - imgread - - - imgread - - - imgread - - - oslib - - - - - cfg - - - - emitter - - - emitter - - - emitter - - - emitter - - - emitter - - - emitter - - - emitter - - - emitter - - - emitter - - - emitter - - - profiler - - - hw\holly - - - hw\holly - - - hw\flashrom - - - hw\holly - - - hw\sh4 - - - oslib - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\modules - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\dyna - - - hw\sh4\interpr - - - hw\sh4\modules - - - hw\sh4 - - - hw\sh4 - - - hw\sh4 - - - hw\sh4 - - - hw\sh4 - - - hw\sh4 - - - deps\libelf - - - deps\libelf - - - deps\libelf - - - deps\libelf - - - linux - - - deps\chdpsr - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - deps\libpng - - - rend\gles - - - rend - - - rend - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - deps\libwebsocket - - - webui - - - deps\coreio - - - reios - - - reios - - - reios - - - reios - - - linux - - - oslib - - - rec-x86 - - - hw\naomi - - - hw\naomi - - - hw\naomi - - - cfg - - - hw\sh4\modules - - - rend\gl4 - - - rend\gl4 - - - hw\modem - - - hw\modem - - - hw\modem - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - hw\pvr - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\lzma - - - deps\flac\include\FLAC - - - deps\flac\include\FLAC - - - deps\flac\include\FLAC - - - deps\flac\include\FLAC - - - deps\flac\include\FLAC - - - deps\flac\include\FLAC - - - deps\flac\include\FLAC - - - deps\flac\include\FLAC - - - deps\flac\include\FLAC - - - deps\flac\include\share - - - deps\flac\include\share - - - deps\flac\include\share - - - deps\flac\include\share - - - deps\flac\include\share - - - deps\flac\include\share - - - deps\flac\include\share - - - deps\chdr - - - deps\chdr - - - deps\chdr - - - deps\chdr - - - - - deps\zlib - - - rec-ARM - - - rec-x86 - - + + + + + hw\aica + + + hw\aica + + + hw\aica + + + hw\aica + + + hw\aica + + + hw\arm7 + + + hw\arm7 + + + hw\arm7 + + + hw\arm7 + + + hw\gdrom + + + hw\gdrom + + + hw\maple + + + hw\maple + + + hw\maple + + + hw\maple + + + hw\mem + + + hw\sh4 + + + hw\pvr + + + hw\pvr + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\crypto + + + deps\crypto + + + imgread + + + imgread + + + imgread + + + imgread + + + imgread + + + imgread + + + + + cfg + + + cfg + + + emitter + + + windows + + + profiler + + + hw\holly + + + hw\holly + + + hw\holly + + + hw\sh4 + + + oslib + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\interpr + + + hw\sh4\interpr + + + hw\sh4\interpr + + + hw\sh4 + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4 + + + hw\sh4 + + + hw\sh4 + + + hw\sh4 + + + deps\libelf + + + deps\libelf + + + deps\libelf + + + linux + + + linux + + + deps\chdpsr + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + rend\gles + + + rend\gles + + + rend\gles + + + rend + + + rend\d3d11 + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + webui + + + deps\coreio + + + reios + + + reios + + + reios + + + reios + + + linux + + + oslib + + + rec-ARM + + + rec-x86 + + + rec-x86 + + + rec-x86 + + + rec-x64 + + + rec-cpp + + + rend\soft + + + hw\naomi + + + hw\naomi + + + cfg + + + + deps\xxhash + + + rend\gl4 + + + rend\gl4 + + + rend\gl4 + + + rend\gl4 + + + hw\aica + + + hw\modem + + + hw\modem + + + deps\xbrz + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\flac\src\libFLAC + + + deps\chdr + + + deps\chdr + + + deps\chdr + + + deps\chdr + + + deps\chdr + + + rend + + + rend + + + deps\imgui + + + deps\imgui + + + deps\imgui + + + deps\imgui + + + deps\dirent + + + input + + + input + + + input + + + rend\gles + + + rend\gles + + + rend\gles + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + archive + + + archive + + + archive + + + imgread + + + + + {2099cae6-67fb-489f-b082-7555e8330705} + + + {70620682-2709-4701-b0a7-7d8f8e1571de} + + + {9659b21d-ccee-4d2b-973d-09e447be743e} + + + {a07a09a2-a585-4144-a0d0-c54d4bb442ec} + + + {9da5f3a4-2e41-4f94-a499-e2524c4dd0c2} + + + {c3e9aa73-a90e-4f37-b357-b0378fb1feff} + + + {65dd7d80-739d-4b5c-a01c-3262cb8ec97a} + + + {da5bfaf9-fca7-4397-9034-e201c1f38e49} + + + {ee2a1c0f-d38c-4d2b-bb07-ba6841fc5832} + + + {09e0d071-e3c1-4549-b2a8-52f24f4691a8} + + + {d0252230-b46c-424f-8aa8-037774915f81} + + + {5cdde132-a201-4bbc-9dd4-2ba3b3637a19} + + + {bd80604a-c634-44b3-a729-811bbefd3f71} + + + {8783a652-88e4-49bf-be90-bc36abe6753b} + + + {2e4fe5a7-a86c-45cf-b456-39b107a91bc7} + + + {369d7f53-be71-4055-a303-675f1132b118} + + + {e14356dc-6635-49f9-94d5-dc14ff1dec70} + + + {f96b3c39-1255-4ee8-999e-5c6e8fef21e5} + + + {b81a858a-7327-4eb4-bc6b-6ae24e2c08fd} + + + {755fe7c9-b6b5-42e5-b0e6-d1d02d5a6e03} + + + {2bbf43fd-2127-412f-bd76-6260b04522f8} + + + {be756ece-25e8-4a69-b90e-2601fdbb42fe} + + + {66246039-9de4-4bc0-88a9-94582e2713e0} + + + {3ef102e4-a05f-4774-b2d7-7e1529bfd9b1} + + + {82948f1f-819b-4a2d-9e07-72dfbf3e96ca} + + + {fe073008-ffba-43c1-9192-daec4b48148e} + + + {fa363b78-585a-476a-9afc-628b0f6650cf} + + + {3f5c03ee-36db-4818-b0d2-4eec9c084f75} + + + {cd2c89fd-7a5b-43c8-a940-6ea0d29e9b5d} + + + {cc05f61b-c484-40e6-9859-6ca0cd64735c} + + + {3d3de3ff-9e79-4920-a95a-61d190e73004} + + + {81193efc-656a-4154-9adf-146856d4c7d3} + + + {23cfa286-fe88-439d-89de-a6a5a23cacc9} + + + {f614dd66-5d30-4548-a209-f857f95fb505} + + + {df854851-d3b5-4549-8248-acdfa954be44} + + + {5a7b63eb-8c03-46ac-b6e0-dfd3ade02f11} + + + {f73263e9-dbe8-4a6f-8b73-335af8307551} + + + {63d1fcf2-64b4-4973-995f-cd471f51117c} + + + {6c4b2d69-54c0-4660-9969-a98fd0339a15} + + + {1752487d-0739-47bf-8c6b-1d38e6f389f7} + + + {83d7e5cc-cbd2-40e3-b2c0-79cc53b1dd9a} + + + {e9e574e5-cce8-467b-8457-acf3999240c1} + + + {c1ffb17b-f29e-466a-a6a6-e93aa1bb2ca7} + + + {a67aece4-e47f-48a2-8944-6afbe679a5fb} + + + {4c0328b2-a9b3-4b0a-ab54-558ba960b03a} + + + {8bb0b4a0-7661-4533-9245-fc43582f6182} + + + {98226656-1e2d-4d69-bcd4-c1c1b6d4cb0a} + + + {f06382df-ae0e-459c-92a2-dc0eaab25b05} + + + {39e82b10-530a-4978-b8cc-8a11b67981d7} + + + {51e03f58-a90d-4ebc-95f7-6af6cdc39165} + + + {4c52c0a3-9e35-4285-a062-290d3667e1d1} + + + {0746d3c7-838f-43ed-817b-8215a24b87d4} + + + {29043329-ba53-45d5-8513-a5ee92c73853} + + + {ff6259dd-375b-46bb-a2ad-bf2825eb81ee} + + + {8fea504f-a313-4ab2-b25b-74e80fe449c8} + + + + + hw\aica + + + hw\aica + + + hw\aica + + + hw\aica + + + hw\aica + + + hw\arm7 + + + hw\arm7 + + + hw\arm7 + + + hw\arm7 + + + hw\gdrom + + + hw\gdrom + + + hw\maple + + + hw\maple + + + hw\maple + + + hw\maple + + + hw\mem + + + hw\sh4 + + + hw\sh4 + + + hw\sh4 + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\zlib + + + deps\crypto + + + deps\crypto + + + deps\chdr + + + deps\chdr + + + imgread + + + imgread + + + imgread + + + imgread + + + imgread + + + imgread + + + oslib + + + + + cfg + + + + emitter + + + emitter + + + emitter + + + emitter + + + emitter + + + emitter + + + emitter + + + emitter + + + emitter + + + emitter + + + profiler + + + hw\holly + + + hw\holly + + + hw\flashrom + + + hw\holly + + + hw\sh4 + + + oslib + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\modules + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\dyna + + + hw\sh4\interpr + + + hw\sh4\modules + + + hw\sh4 + + + hw\sh4 + + + hw\sh4 + + + hw\sh4 + + + hw\sh4 + + + hw\sh4 + + + deps\libelf + + + deps\libelf + + + deps\libelf + + + deps\libelf + + + linux + + + deps\chdpsr + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + deps\libpng + + + rend\gles + + + rend + + + rend + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + deps\libwebsocket + + + webui + + + deps\coreio + + + reios + + + reios + + + reios + + + reios + + + linux + + + oslib + + + rec-x86 + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + cfg + + + hw\sh4\modules + + + rend\gl4 + + + rend\gl4 + + + hw\modem + + + hw\modem + + + hw\modem + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + hw\pvr + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\lzma + + + deps\flac\include\FLAC + + + deps\flac\include\FLAC + + + deps\flac\include\FLAC + + + deps\flac\include\FLAC + + + deps\flac\include\FLAC + + + deps\flac\include\FLAC + + + deps\flac\include\FLAC + + + deps\flac\include\FLAC + + + deps\flac\include\FLAC + + + deps\flac\include\share + + + deps\flac\include\share + + + deps\flac\include\share + + + deps\flac\include\share + + + deps\flac\include\share + + + deps\flac\include\share + + + deps\flac\include\share + + + deps\chdr + + + deps\chdr + + + deps\chdr + + + deps\chdr + + + rend + + + rend + + + deps\imgui + + + deps\imgui + + + deps\imgui + + + deps\imgui + + + deps\imgui + + + deps\imgui + + + deps\imgui + + + deps\dirent + + + input + + + input + + + input + + + input + + + rend\gles + + + rend\gles + + + rend\gles + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + hw\naomi + + + archive + + + archive + + + archive + + + windows + + + windows + + + + + deps\zlib + + + rec-ARM + + + rec-x86 + + + + + \ No newline at end of file From 8992549e47b4c10a8360c047a494cc22242319ad Mon Sep 17 00:00:00 2001 From: flyinghead Date: Sat, 30 Mar 2019 19:44:38 +0100 Subject: [PATCH 06/73] appveyor: archive stripped exe to save space --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index dab32d51c..51b133577 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,7 +18,7 @@ build_script: after_build: - cmd: cd ..\.. - cmd: mkdir artifacts - - cmd: move shell\linux\reicast.exe artifacts/reicast-win_x64-fast-%APPVEYOR_REPO_COMMIT%.exe + - cmd: move shell\linux\nosym-reicast.exe artifacts/reicast-win_x64-fast-%APPVEYOR_REPO_COMMIT%.exe - cmd: copy %EXTRA_PATH%\libgcc_s_seh-1.dll artifacts - cmd: copy %EXTRA_PATH%\libwinpthread-1.dll artifacts - cmd: copy %EXTRA_PATH%\libgomp-1.dll artifacts From 2d03662a9ac3137c5b28a16294b0f1001da57abd Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Wed, 3 Apr 2019 18:39:57 +0200 Subject: [PATCH 07/73] android: run the vibrator in a separate thread avoid lag when spamming the touchscreen controls --- .../emulator/emu/VirtualJoystickDelegate.java | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/VirtualJoystickDelegate.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/VirtualJoystickDelegate.java index 68f35545b..aeddce39b 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/VirtualJoystickDelegate.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/VirtualJoystickDelegate.java @@ -15,7 +15,7 @@ import com.reicast.emulator.periph.InputDeviceManager; import com.reicast.emulator.periph.VJoy; public class VirtualJoystickDelegate { - private Vibrator vib; + private VibratorThread vibratorThread; private boolean editVjoyMode = false; private int selectedVjoyElement = -1; @@ -39,7 +39,10 @@ public class VirtualJoystickDelegate { public VirtualJoystickDelegate(View view) { this.view = view; this.context = view.getContext(); - vib = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); + + vibratorThread = new VibratorThread(context); + vibratorThread.start(); + readCustomVjoyValues(); scaleGestureDetector = new ScaleGestureDetector(context, new OscOnScaleGestureListener()); } @@ -224,8 +227,9 @@ public class VirtualJoystickDelegate { if (y > vjoy[j][1] && y <= (vjoy[j][1] + vjoy[j][3])) { if (vjoy[j][4] >= -2) { if (vjoy[j][5] == 0) - if (!editVjoyMode && Emulator.vibrationDuration > 0) - vib.vibrate(Emulator.vibrationDuration); + if (!editVjoyMode) { + vibratorThread.vibrate(); + } vjoy[j][5] = 2; } @@ -397,4 +401,47 @@ public class VirtualJoystickDelegate { selectedVjoyElement = -1; } } + + private class VibratorThread extends Thread + { + private Vibrator vibrator; + private boolean vibrate = false; + private boolean stopping = false; + + VibratorThread(Context context) { + vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); + } + + @Override + public void run() { + while (!stopping) { + synchronized (this) { + try { + this.wait(); + } catch (InterruptedException e) { + } + if (vibrate) { + vibrator.vibrate(Emulator.vibrationDuration); + vibrate = false; + } + } + } + } + + public void stopVibrator() { + synchronized (this) { + stopping = true; + notify(); + } + } + + public void vibrate() { + if (Emulator.vibrationDuration > 0) { + synchronized (this) { + vibrate = true; + notify(); + } + } + } + } } From cc26e255e04db5f871b80d9eaeb4c27bb5485211 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Wed, 3 Apr 2019 18:49:40 +0200 Subject: [PATCH 08/73] android: vibrate out of the synchronized section --- .../com/reicast/emulator/emu/VirtualJoystickDelegate.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/VirtualJoystickDelegate.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/VirtualJoystickDelegate.java index aeddce39b..e3e142adf 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/VirtualJoystickDelegate.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/VirtualJoystickDelegate.java @@ -415,16 +415,20 @@ public class VirtualJoystickDelegate { @Override public void run() { while (!stopping) { + boolean doVibrate; synchronized (this) { + doVibrate = false; try { this.wait(); } catch (InterruptedException e) { } if (vibrate) { - vibrator.vibrate(Emulator.vibrationDuration); + doVibrate = true; vibrate = false; } } + if (doVibrate) + vibrator.vibrate(Emulator.vibrationDuration); } } From f83a06d9c0e8847b1111c6f6f7ded5d7317bf18a Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 4 Apr 2019 19:06:46 +0200 Subject: [PATCH 09/73] glcache was always disabled --- core/rend/gles/glcache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rend/gles/glcache.h b/core/rend/gles/glcache.h index d7f292af9..e245a368d 100644 --- a/core/rend/gles/glcache.h +++ b/core/rend/gles/glcache.h @@ -179,7 +179,7 @@ public: void DisableCache() { _disable_cache = true; } void EnableCache() { - _disable_cache = true; + _disable_cache = false; Reset(); } From 382279b12eebe7941003497f21b3b3aaf472bbb1 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 4 Apr 2019 19:07:09 +0200 Subject: [PATCH 10/73] imgui: use glcache --- core/rend/gles/imgui_impl_opengl3.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/rend/gles/imgui_impl_opengl3.cpp b/core/rend/gles/imgui_impl_opengl3.cpp index fce30f9fa..2857a19d5 100644 --- a/core/rend/gles/imgui_impl_opengl3.cpp +++ b/core/rend/gles/imgui_impl_opengl3.cpp @@ -67,6 +67,7 @@ #endif #include "gles.h" +#include "glcache.h" // OpenGL Data static char g_GlslVersionString[32] = ""; @@ -588,11 +589,10 @@ void ImGui_ImplOpenGL3_DrawBackground() ImTextureID ImGui_ImplOpenGL3_CreateVmuTexture(const unsigned int *data) { - GLuint tex_id; - glGenTextures(1, &tex_id); - glBindTexture(GL_TEXTURE_2D, tex_id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + GLuint tex_id = glcache.GenTexture(); + glcache.BindTexture(GL_TEXTURE_2D, tex_id); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 48, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); return reinterpret_cast(tex_id); @@ -600,5 +600,5 @@ ImTextureID ImGui_ImplOpenGL3_CreateVmuTexture(const unsigned int *data) void ImGui_ImplOpenGL3_DeleteVmuTexture(ImTextureID tex_id) { - glDeleteTextures(1, &(GLuint &)tex_id); + glcache.DeleteTextures(1, &(GLuint &)tex_id); } From 994d52e012e28d79d44d9e392f5f26f5319afa5e Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 4 Apr 2019 19:08:21 +0200 Subject: [PATCH 11/73] gl: put shaders in a map and set uniforms once for all before each frame --- core/rend/gles/gldraw.cpp | 46 +++++++----------- core/rend/gles/gles.cpp | 99 +++++++++++---------------------------- core/rend/gles/gles.h | 9 ++-- 3 files changed, 49 insertions(+), 105 deletions(-) diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index 5ed09a66e..e735ea99f 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -174,27 +174,23 @@ __forceinline bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff); - CurrentShader = &gl.pogram_table[ - GetProgramID(Type == ListType_Punch_Through ? 1 : 0, - SetTileClip(gp->tileclip, -1) + 1, - gp->pcw.Texture, - gp->tsp.UseAlpha, - gp->tsp.IgnoreTexA, - gp->tsp.ShadInstr, - gp->pcw.Offset, - gp->tsp.FogCtrl, - gp->pcw.Gouraud, - gp->tcw.PixelFmt == PixelBumpMap, - color_clamp, - ShaderUniforms.trilinear_alpha != 1.f)]; + CurrentShader = GetProgram(Type == ListType_Punch_Through ? 1 : 0, + SetTileClip(gp->tileclip, -1) + 1, + gp->pcw.Texture, + gp->tsp.UseAlpha, + gp->tsp.IgnoreTexA, + gp->tsp.ShadInstr, + gp->pcw.Offset, + gp->tsp.FogCtrl, + gp->pcw.Gouraud, + gp->tcw.PixelFmt == PixelBumpMap, + color_clamp, + ShaderUniforms.trilinear_alpha != 1.f); - if (CurrentShader->program == -1) - CompilePipelineShader(CurrentShader); - else - { - glcache.UseProgram(CurrentShader->program); - ShaderUniforms.Set(CurrentShader); - } + glcache.UseProgram(CurrentShader->program); + if (CurrentShader->trilinear_alpha != -1) + glUniform1f(CurrentShader->trilinear_alpha, ShaderUniforms.trilinear_alpha); + SetTileClip(gp->tileclip, CurrentShader->pp_ClipTest); //This bit control which pixels are affected @@ -1122,14 +1118,8 @@ static void DrawQuad(GLuint texId, float x, float y, float w, float h, float u0, ShaderUniforms.trilinear_alpha = 1.0; - PipelineShader *shader = &gl.pogram_table[GetProgramID(0, 1, 1, 0, 1, 0, 0, 2, false, false, false, false)]; - if (shader->program == -1) - CompilePipelineShader(shader); - else - { - glcache.UseProgram(shader->program); - ShaderUniforms.Set(shader); - } + PipelineShader *shader = GetProgram(0, 1, 1, 0, 1, 0, 0, 2, false, false, false, false); + glcache.UseProgram(shader->program); glActiveTexture(GL_TEXTURE0); glcache.BindTexture(GL_TEXTURE_2D, texId); diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index 6965ec97d..e88b70a7a 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -865,7 +865,7 @@ static void gles_term() gl_free_osd_resources(); free_output_framebuffer(); - memset(gl.pogram_table, 0, sizeof(gl.pogram_table)); + gl.shaders.clear(); gl_term(); } @@ -1014,7 +1014,7 @@ GLuint gl_CompileAndLink(const char* VertexShader, const char* FragmentShader) return program; } -int GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode, +PipelineShader *GetProgram(u32 cp_AlphaTest, u32 pp_ClipTestMode, u32 pp_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset, u32 pp_FogCtrl, bool pp_Gouraud, bool pp_BumpMap, bool fog_clamping, bool trilinear) { @@ -1033,7 +1033,25 @@ int GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode, rv<<=1; rv|=fog_clamping; rv<<=1; rv|=trilinear; - return rv; + PipelineShader *shader = &gl.shaders[rv]; + if (shader->program == 0) + { + shader->cp_AlphaTest = cp_AlphaTest; + shader->pp_ClipTestMode = pp_ClipTestMode-1; + shader->pp_Texture = pp_Texture; + shader->pp_UseAlpha = pp_UseAlpha; + shader->pp_IgnoreTexA = pp_IgnoreTexA; + shader->pp_ShadInstr = pp_ShadInstr; + shader->pp_Offset = pp_Offset; + shader->pp_FogCtrl = pp_FogCtrl; + shader->pp_Gouraud = pp_Gouraud; + shader->pp_BumpMap = pp_BumpMap; + shader->fog_clamping = fog_clamping; + shader->trilinear = trilinear; + CompilePipelineShader(shader); + } + + return shader; } bool CompilePipelineShader( PipelineShader* s) @@ -1156,65 +1174,6 @@ bool gl_create_resources() glGenBuffers(1, &gl.vbo.idxs); glGenBuffers(1, &gl.vbo.idxs2); - memset(gl.pogram_table,0,sizeof(gl.pogram_table)); - - PipelineShader* dshader=0; - u32 compile=0; -#define forl(name,max) for(u32 name=0;name<=max;name++) - forl(cp_AlphaTest,1) - { - forl(pp_ClipTestMode,2) - { - forl(pp_UseAlpha,1) - { - forl(pp_Texture,1) - { - forl(pp_FogCtrl,3) - { - forl(pp_IgnoreTexA,1) - { - forl(pp_ShadInstr,3) - { - forl(pp_Offset,1) - { - forl(pp_Gouraud,1) - { - forl(pp_BumpMap,1) - { - forl(fog_clamping,1) - { - forl(trilinear,1) - { - dshader=&gl.pogram_table[GetProgramID(cp_AlphaTest,pp_ClipTestMode,pp_Texture,pp_UseAlpha,pp_IgnoreTexA, - pp_ShadInstr,pp_Offset,pp_FogCtrl, (bool)pp_Gouraud, (bool)pp_BumpMap, (bool)fog_clamping, - (bool)trilinear)]; - - dshader->cp_AlphaTest = cp_AlphaTest; - dshader->pp_ClipTestMode = pp_ClipTestMode-1; - dshader->pp_Texture = pp_Texture; - dshader->pp_UseAlpha = pp_UseAlpha; - dshader->pp_IgnoreTexA = pp_IgnoreTexA; - dshader->pp_ShadInstr = pp_ShadInstr; - dshader->pp_Offset = pp_Offset; - dshader->pp_FogCtrl = pp_FogCtrl; - dshader->pp_Gouraud = pp_Gouraud; - dshader->pp_BumpMap = pp_BumpMap; - dshader->fog_clamping = fog_clamping; - dshader->trilinear = trilinear; - dshader->program = -1; - } - } - } - } - } - } - } - } - } - } - } - } - char vshader[8192]; sprintf(vshader, VertexShaderSource, gl.glsl_version_header, gl.gl_version, 1); char fshader[8192]; @@ -1782,16 +1741,12 @@ bool RenderFrame() ShaderUniforms.PT_ALPHA=(PT_ALPHA_REF&0xFF)/255.0f; -// for (u32 i=0;iprogram == -1) -// continue; -// -// glcache.UseProgram(s->program); -// -// ShaderUniforms.Set(s); -// } + for (auto it : gl.shaders) + { + glcache.UseProgram(it.second.program); + ShaderUniforms.Set(&it.second); + } + //setup render target first if (is_rtt) { diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index 2b907c156..282cb27fb 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -1,4 +1,5 @@ #pragma once +#include #include "rend/rend.h" #if (defined(GLES) && !defined(TARGET_NACL32) && HOST_OS != OS_DARWIN && !defined(USE_SDL)) || defined(_ANDROID) @@ -93,7 +94,8 @@ struct gl_ctx } modvol_shader; - PipelineShader pogram_table[24576]; + std::map shaders; + struct { GLuint program; @@ -176,7 +178,7 @@ void free_output_framebuffer(); void HideOSD(); void OSD_DRAW(bool clear_screen); -int GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode, +PipelineShader *GetProgram(u32 cp_AlphaTest, u32 pp_ClipTestMode, u32 pp_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset, u32 pp_FogCtrl, bool pp_Gouraud, bool pp_BumpMap, bool fog_clamping, bool trilinear); @@ -223,9 +225,6 @@ extern struct ShaderUniforms_t if (s->sp_FOG_COL_VERT!=-1) glUniform3fv( s->sp_FOG_COL_VERT, 1, ps_FOG_COL_VERT); - if (s->trilinear_alpha != -1) - glUniform1f(s->trilinear_alpha, trilinear_alpha); - if (s->fog_clamp_min != -1) glUniform4fv(s->fog_clamp_min, 1, fog_clamp_min); if (s->fog_clamp_max != -1) From ec95c95b89178c9090c14b2f78c26a563593bef6 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 4 Apr 2019 19:26:15 +0200 Subject: [PATCH 12/73] add option to disable fog effects --- core/nullDC.cpp | 3 +++ core/rend/gl4/gldraw.cpp | 4 +++- core/rend/gles/gldraw.cpp | 3 ++- core/types.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/nullDC.cpp b/core/nullDC.cpp index e770b3c08..89c637803 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -513,6 +513,7 @@ void InitSettings() settings.rend.CustomTextures = false; settings.rend.DumpTextures = false; settings.rend.ScreenScaling = 100; + settings.rend.Fog = true; settings.pvr.ta_skip = 0; settings.pvr.rend = 0; @@ -595,6 +596,7 @@ void LoadSettings(bool game_specific) settings.rend.DumpTextures = cfgLoadBool(config_section, "rend.DumpTextures", settings.rend.DumpTextures); settings.rend.ScreenScaling = cfgLoadInt(config_section, "rend.ScreenScaling", settings.rend.ScreenScaling); settings.rend.ScreenScaling = min(max(1, settings.rend.ScreenScaling), 100); + settings.rend.Fog = cfgLoadBool(config_section, "rend.Fog", settings.rend.Fog); settings.pvr.ta_skip = cfgLoadInt(config_section, "ta.skip", settings.pvr.ta_skip); settings.pvr.rend = cfgLoadInt(config_section, "pvr.rend", settings.pvr.rend); @@ -718,6 +720,7 @@ void SaveSettings() cfgSaveBool("config", "rend.CustomTextures", settings.rend.CustomTextures); cfgSaveBool("config", "rend.DumpTextures", settings.rend.DumpTextures); cfgSaveInt("config", "rend.ScreenScaling", settings.rend.ScreenScaling); + cfgSaveBool("config", "rend.Fog", settings.rend.Fog); cfgSaveInt("config", "ta.skip", settings.pvr.ta_skip); cfgSaveInt("config", "pvr.rend", settings.pvr.rend); diff --git a/core/rend/gl4/gldraw.cpp b/core/rend/gl4/gldraw.cpp index 3342325d7..21ec3e923 100644 --- a/core/rend/gl4/gldraw.cpp +++ b/core/rend/gl4/gldraw.cpp @@ -153,6 +153,8 @@ template bool two_volumes_mode = (gp->tsp1.full != -1) && Type != ListType_Translucent; bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff); + int fog_ctrl = settings.rend.Fog ? gp->tsp.FogCtrl : 2; + int depth_func = 0; if (Type == ListType_Translucent) { @@ -169,7 +171,7 @@ template gp->tsp.IgnoreTexA, gp->tsp.ShadInstr, gp->pcw.Offset, - gp->tsp.FogCtrl, + fog_ctrl, two_volumes_mode, depth_func, gp->pcw.Gouraud, diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index e735ea99f..d337848cb 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -173,6 +173,7 @@ __forceinline ShaderUniforms.trilinear_alpha = 1.f; bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff); + int fog_ctrl = settings.rend.Fog ? gp->tsp.FogCtrl : 2; CurrentShader = GetProgram(Type == ListType_Punch_Through ? 1 : 0, SetTileClip(gp->tileclip, -1) + 1, @@ -181,7 +182,7 @@ __forceinline gp->tsp.IgnoreTexA, gp->tsp.ShadInstr, gp->pcw.Offset, - gp->tsp.FogCtrl, + fog_ctrl, gp->pcw.Gouraud, gp->tcw.PixelFmt == PixelBumpMap, color_clamp, diff --git a/core/types.h b/core/types.h index 9d2e54d4d..a9a835ac1 100644 --- a/core/types.h +++ b/core/types.h @@ -633,6 +633,7 @@ struct settings_t bool CustomTextures; bool DumpTextures; int ScreenScaling; // in percent. 50 means half the native resolution + bool Fog; } rend; struct From 3a7393824063d9157f034bfb36c2ee069d8f4b37 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 4 Apr 2019 20:05:13 +0200 Subject: [PATCH 13/73] UI for fog disable option --- core/rend/gui.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 03e976d85..a8a35edf2 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -940,6 +940,9 @@ static void gui_display_settings() ImGui::Checkbox("Shadows", &settings.rend.ModifierVolumes); ImGui::SameLine(); ShowHelpMarker("Enable modifier volumes, usually used for shadows"); + ImGui::Checkbox("Fog", &settings.rend.Fog); + ImGui::SameLine(); + ShowHelpMarker("Enable fog effects"); ImGui::Checkbox("Widescreen", &settings.rend.WideScreen); ImGui::SameLine(); ShowHelpMarker("Draw geometry outside of the normal 4:3 aspect ratio. May produce graphical glitches in the revealed areas"); From 05df2f06e20c91954dab7fe861f56a3d383664d9 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 4 Apr 2019 22:26:21 +0200 Subject: [PATCH 14/73] imgui: use glcache, don't save/restore state gl4: backport shader map changes from gl renderer --- core/rend/gl4/gl4.h | 14 +--- core/rend/gl4/gldraw.cpp | 66 ++++++----------- core/rend/gl4/gles.cpp | 5 +- core/rend/gles/gles.h | 4 +- core/rend/gles/imgui_impl_opengl3.cpp | 102 ++++++-------------------- core/rend/gui.cpp | 18 ----- 6 files changed, 51 insertions(+), 158 deletions(-) diff --git a/core/rend/gl4/gl4.h b/core/rend/gl4/gl4.h index 7abc1db20..5ca4dd141 100755 --- a/core/rend/gl4/gl4.h +++ b/core/rend/gl4/gl4.h @@ -1,6 +1,6 @@ #pragma once #include "rend/gles/gles.h" -#include +#include void gl4DrawStrips(GLuint output_fbo); @@ -44,7 +44,7 @@ struct gl4_ctx GLuint extra_depth_scale; } modvol_shader; - std::map shaders; + std::unordered_map shaders; struct { @@ -53,16 +53,6 @@ struct gl4_ctx GLuint modvol_vao; GLuint tr_poly_params; } vbo; - - gl4PipelineShader *getShader(int programId) { - gl4PipelineShader *shader = shaders[programId]; - if (shader == NULL) { - shader = new gl4PipelineShader(); - shaders[programId] = shader; - shader->program = -1; - } - return shader; - } }; extern gl4_ctx gl4; diff --git a/core/rend/gl4/gldraw.cpp b/core/rend/gl4/gldraw.cpp index 21ec3e923..447a97461 100644 --- a/core/rend/gl4/gldraw.cpp +++ b/core/rend/gl4/gldraw.cpp @@ -45,7 +45,7 @@ static GLuint texSamplers[2]; static GLuint depth_fbo; GLuint depthSaveTexId; -static int gl4GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode, +static gl4PipelineShader *gl4GetProgram(u32 cp_AlphaTest, u32 pp_ClipTestMode, u32 pp_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset, u32 pp_FogCtrl, bool pp_TwoVolumes, u32 pp_DepthFunc, bool pp_Gouraud, bool pp_BumpMap, bool fog_clamping, int pass) { @@ -66,45 +66,27 @@ static int gl4GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode, rv <<= 1; rv |= fog_clamping; rv <<= 2; rv |= pass; - return rv; -} - -static void setCurrentShader(u32 cp_AlphaTest, u32 pp_ClipTestMode, - u32 pp_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset, - u32 pp_FogCtrl, bool pp_TwoVolumes, u32 pp_DepthFunc, bool pp_Gouraud, bool pp_BumpMap, bool fog_clamping, int pass) -{ - int shaderId = gl4GetProgramID(cp_AlphaTest, - pp_ClipTestMode + 1, - pp_Texture, - pp_UseAlpha, - pp_IgnoreTexA, - pp_ShadInstr, - pp_Offset, - pp_FogCtrl, - pp_TwoVolumes, - pp_DepthFunc, - pp_Gouraud, - pp_BumpMap, - fog_clamping, - pass); - CurrentShader = gl4.getShader(shaderId); - if (CurrentShader->program == -1) { - CurrentShader->cp_AlphaTest = cp_AlphaTest; - CurrentShader->pp_ClipTestMode = pp_ClipTestMode; - CurrentShader->pp_Texture = pp_Texture; - CurrentShader->pp_UseAlpha = pp_UseAlpha; - CurrentShader->pp_IgnoreTexA = pp_IgnoreTexA; - CurrentShader->pp_ShadInstr = pp_ShadInstr; - CurrentShader->pp_Offset = pp_Offset; - CurrentShader->pp_FogCtrl = pp_FogCtrl; - CurrentShader->pp_TwoVolumes = pp_TwoVolumes; - CurrentShader->pp_DepthFunc = pp_DepthFunc; - CurrentShader->pp_Gouraud = pp_Gouraud; - CurrentShader->pp_BumpMap = pp_BumpMap; - CurrentShader->fog_clamping = fog_clamping; - CurrentShader->pass = pass; - gl4CompilePipelineShader(CurrentShader); + gl4PipelineShader *shader = &gl4.shaders[rv]; + if (shader->program == 0) + { + shader->cp_AlphaTest = cp_AlphaTest; + shader->pp_ClipTestMode = pp_ClipTestMode; + shader->pp_Texture = pp_Texture; + shader->pp_UseAlpha = pp_UseAlpha; + shader->pp_IgnoreTexA = pp_IgnoreTexA; + shader->pp_ShadInstr = pp_ShadInstr; + shader->pp_Offset = pp_Offset; + shader->pp_FogCtrl = pp_FogCtrl; + shader->pp_TwoVolumes = pp_TwoVolumes; + shader->pp_DepthFunc = pp_DepthFunc; + shader->pp_Gouraud = pp_Gouraud; + shader->pp_BumpMap = pp_BumpMap; + shader->fog_clamping = fog_clamping; + shader->pass = pass; + gl4CompilePipelineShader(shader); } + + return shader; } static void SetTextureRepeatMode(int index, GLuint dir, u32 clamp, u32 mirror) @@ -132,7 +114,7 @@ template if (pass == 0) { - setCurrentShader(Type == ListType_Punch_Through ? 1 : 0, + CurrentShader = gl4GetProgram(Type == ListType_Punch_Through ? 1 : 0, clipping, Type == ListType_Punch_Through ? gp->pcw.Texture : 0, 1, @@ -164,7 +146,7 @@ template depth_func = gp->isp.DepthMode; } - setCurrentShader(Type == ListType_Punch_Through ? 1 : 0, + CurrentShader = gl4GetProgram(Type == ListType_Punch_Through ? 1 : 0, clipping, gp->pcw.Texture, gp->tsp.UseAlpha, @@ -683,7 +665,7 @@ static void gl4_draw_quad_texture(GLuint texture, bool upsideDown, float x = 0.f ShaderUniforms.trilinear_alpha = 1.0; - setCurrentShader(0, + CurrentShader = gl4GetProgram(0, 0, 1, 0, diff --git a/core/rend/gl4/gles.cpp b/core/rend/gl4/gles.cpp index 505b1d23f..5db1d336d 100644 --- a/core/rend/gl4/gles.cpp +++ b/core/rend/gl4/gles.cpp @@ -489,9 +489,8 @@ static void gles_term(void) glDeleteBuffers(1, &gl4.vbo.tr_poly_params); for (auto it = gl4.shaders.begin(); it != gl4.shaders.end(); it++) { - if (it->second->program != -1) - glDeleteProgram(it->second->program); - delete it->second; + if (it->second.program != 0) + glDeleteProgram(it->second.program); } gl4.shaders.clear(); glDeleteVertexArrays(1, &gl4.vbo.main_vao); diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index 282cb27fb..832ecf31a 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -1,5 +1,5 @@ #pragma once -#include +#include #include "rend/rend.h" #if (defined(GLES) && !defined(TARGET_NACL32) && HOST_OS != OS_DARWIN && !defined(USE_SDL)) || defined(_ANDROID) @@ -94,7 +94,7 @@ struct gl_ctx } modvol_shader; - std::map shaders; + std::unordered_map shaders; struct { diff --git a/core/rend/gles/imgui_impl_opengl3.cpp b/core/rend/gles/imgui_impl_opengl3.cpp index 2857a19d5..853e41563 100644 --- a/core/rend/gles/imgui_impl_opengl3.cpp +++ b/core/rend/gles/imgui_impl_opengl3.cpp @@ -128,28 +128,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr draw_data->ScaleClipRects(io.DisplayFramebufferScale); // Backup GL state - GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture); glActiveTexture(GL_TEXTURE0); - GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); - GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler); - GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer); - GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array); -#ifdef GL_POLYGON_MODE - GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); -#endif - GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport); - GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box); - GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb); - GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb); - GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha); - GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha); - GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb); - GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha); - GLboolean last_enable_blend = glIsEnabled(GL_BLEND); - GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE); - GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST); - GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST); bool clip_origin_lower_left = true; #ifdef GL_CLIP_ORIGIN if (gl.gl_major >= 4 && glClipControl != NULL) @@ -167,13 +146,13 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr // (Re-)create the background texture and reserve space for it if (g_BackgroundTexture != 0) - glDeleteTextures(1, &g_BackgroundTexture); - glGenTextures(1, &g_BackgroundTexture); - glBindTexture(GL_TEXTURE_2D, g_BackgroundTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glcache.DeleteTextures(1, &g_BackgroundTexture); + g_BackgroundTexture = glcache.GenTexture(); + glcache.BindTexture(GL_TEXTURE_2D, g_BackgroundTexture); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fb_width, fb_height, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)NULL); // Copy the current framebuffer into it @@ -181,12 +160,12 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr } // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill - glEnable(GL_BLEND); + glcache.Enable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glEnable(GL_SCISSOR_TEST); + glcache.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glcache.Disable(GL_CULL_FACE); + glcache.Disable(GL_DEPTH_TEST); + glcache.Enable(GL_SCISSOR_TEST); #ifdef GL_POLYGON_MODE if (glPolygonMode != NULL) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); @@ -206,7 +185,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr { 0.0f, 0.0f, -1.0f, 0.0f }, { (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f }, }; - glUseProgram(g_ShaderHandle); + glcache.UseProgram(g_ShaderHandle); glUniform1i(g_AttribLocationTex, 0); glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]); if (gl.gl_major >= 3 && glBindSampler != NULL) @@ -261,7 +240,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr glScissor((int)clip_rect.x, (int)clip_rect.y, (int)clip_rect.z, (int)clip_rect.w); // Support for GL 4.5's glClipControl(GL_UPPER_LEFT) // Bind texture, Draw - glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId); + glcache.BindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId); glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset); } } @@ -270,28 +249,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr } if (vao_handle != 0) glDeleteVertexArrays(1, &vao_handle); - - // Restore modified GL state - glUseProgram(last_program); - glBindTexture(GL_TEXTURE_2D, last_texture); - if (gl.gl_major >= 3 && glBindSampler != NULL) - glBindSampler(0, last_sampler); - glActiveTexture(last_active_texture); - glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); - if (gl.gl_major >= 3) - glBindVertexArray(last_vertex_array); - glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha); - glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha); - if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND); - if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); - if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST); - if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST); -#ifdef GL_POLYGON_MODE - if (glPolygonMode != NULL) - glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]); -#endif - glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]); - glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); } bool ImGui_ImplOpenGL3_CreateFontsTexture() @@ -303,21 +260,16 @@ bool ImGui_ImplOpenGL3_CreateFontsTexture() io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. // Upload texture to graphics system - GLint last_texture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glGenTextures(1, &g_FontTexture); - glBindTexture(GL_TEXTURE_2D, g_FontTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + g_FontTexture = glcache.GenTexture(); + glcache.BindTexture(GL_TEXTURE_2D, g_FontTexture); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // Store our identifier io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture; - // Restore state - glBindTexture(GL_TEXTURE_2D, last_texture); - return true; } @@ -326,7 +278,7 @@ void ImGui_ImplOpenGL3_DestroyFontsTexture() if (g_FontTexture) { ImGuiIO& io = ImGui::GetIO(); - glDeleteTextures(1, &g_FontTexture); + glcache.DeleteTextures(1, &g_FontTexture); io.Fonts->TexID = 0; g_FontTexture = 0; } @@ -370,12 +322,6 @@ static bool CheckProgram(GLuint handle, const char* desc) bool ImGui_ImplOpenGL3_CreateDeviceObjects() { - // Backup GL state - GLint last_texture, last_array_buffer, last_vertex_array; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer); - glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array); - // Parse GLSL version string int glsl_version = 130; sscanf(g_GlslVersionString, "#version %d", &glsl_version); @@ -535,12 +481,6 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects() ImGui_ImplOpenGL3_CreateFontsTexture(); - // Restore modified GL state - glBindTexture(GL_TEXTURE_2D, last_texture); - glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); - if (gl.gl_major >= 3) - glBindVertexArray(last_vertex_array); - return true; } @@ -564,7 +504,7 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects() ImGui_ImplOpenGL3_DestroyFontsTexture(); if (g_BackgroundTexture != 0) - glDeleteTextures(1, &g_BackgroundTexture); + glcache.DeleteTextures(1, &g_BackgroundTexture); g_BackgroundTexture = 0; } @@ -582,7 +522,7 @@ void ImGui_ImplOpenGL3_DrawBackground() } else { - glClearColor(0, 0, 0, 0); + glcache.ClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); } } diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index a8a35edf2..cfc134cbc 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -1408,24 +1408,6 @@ void gui_display_ui() gui_state = Closed; } -void gui_display_fps(const char *string) -{ - ImGui_Impl_NewFrame(); - ImGui::NewFrame(); - - ImGui::SetNextWindowBgAlpha(0); - ImGui::SetNextWindowPos(ImVec2(0, screen_height), ImGuiCond_Always, ImVec2(0.f, 1.f)); // Lower left corner - - ImGui::Begin("##fps", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoNav - | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoBackground); - ImGui::SetWindowFontScale(2); - ImGui::TextColored(ImVec4(1, 1, 0, 0.7), "%s", string); - ImGui::End(); - - ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); -} - static float LastFPSTime; static int lastFrameCount = 0; static float fps = -1; From d524e3381d72b5b8d3c2c36863718e38b8b0ff51 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 4 Apr 2019 22:54:36 +0200 Subject: [PATCH 15/73] only update the fog texture if fog is enabled --- core/rend/gl4/gles.cpp | 2 +- core/rend/gles/gles.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/rend/gl4/gles.cpp b/core/rend/gl4/gles.cpp index 5db1d336d..ecda63dec 100644 --- a/core/rend/gl4/gles.cpp +++ b/core/rend/gl4/gles.cpp @@ -703,7 +703,7 @@ static bool RenderFrame() gl4ShaderUniforms.fog_clamp_max[2] = ((pvrrc.fog_clamp_max >> 0) & 0xFF) / 255.0f; gl4ShaderUniforms.fog_clamp_max[3] = ((pvrrc.fog_clamp_max >> 24) & 0xFF) / 255.0f; - if (fog_needs_update) + if (fog_needs_update && settings.rend.Fog) { fog_needs_update = false; UpdateFogTexture((u8 *)FOG_TABLE, GL_TEXTURE5, GL_RED); diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index e88b70a7a..b97d9e4e2 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -1727,7 +1727,7 @@ bool RenderFrame() ShaderUniforms.fog_clamp_max[2] = ((pvrrc.fog_clamp_max >> 0) & 0xFF) / 255.0f; ShaderUniforms.fog_clamp_max[3] = ((pvrrc.fog_clamp_max >> 24) & 0xFF) / 255.0f; - if (fog_needs_update) + if (fog_needs_update && settings.rend.Fog) { fog_needs_update = false; UpdateFogTexture((u8 *)FOG_TABLE, GL_TEXTURE1, gl.fog_image_format); From 0b7024f6a084abd1ec60b57f536eb77ef9b1feb5 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 5 Apr 2019 14:48:59 +0200 Subject: [PATCH 16/73] Avoid opposite dpad buttons being both down. Ignore android key repeats --- core/input/gamepad_device.cpp | 32 +++++++++++++++++++ .../com/reicast/emulator/BaseGLActivity.java | 28 ++++++++-------- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/core/input/gamepad_device.cpp b/core/input/gamepad_device.cpp index 843f18d62..82ccefdf8 100644 --- a/core/input/gamepad_device.cpp +++ b/core/input/gamepad_device.cpp @@ -51,7 +51,39 @@ bool GamepadDevice::gamepad_btn_input(u32 code, bool pressed) if (key < 0x10000) { if (pressed) + { kcode[_maple_port] &= ~(u16)key; + // Avoid two opposite dpad keys being pressed simultaneously + switch (key) + { + case DC_DPAD_UP: + kcode[_maple_port] |= (u16)DC_DPAD_DOWN; + break; + case DC_DPAD_DOWN: + kcode[_maple_port] |= (u16)DC_DPAD_UP; + break; + case DC_DPAD_LEFT: + kcode[_maple_port] |= (u16)DC_DPAD_RIGHT; + break; + case DC_DPAD_RIGHT: + kcode[_maple_port] |= (u16)DC_DPAD_LEFT; + break; + case DC_DPAD2_UP: + kcode[_maple_port] |= (u16)DC_DPAD2_DOWN; + break; + case DC_DPAD2_DOWN: + kcode[_maple_port] |= (u16)DC_DPAD2_UP; + break; + case DC_DPAD2_LEFT: + kcode[_maple_port] |= (u16)DC_DPAD2_RIGHT; + break; + case DC_DPAD2_RIGHT: + kcode[_maple_port] |= (u16)DC_DPAD2_LEFT; + break; + default: + break; + } + } else kcode[_maple_port] |= (u16)key; } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/BaseGLActivity.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/BaseGLActivity.java index f06e02c9a..a0b28e302 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/BaseGLActivity.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/BaseGLActivity.java @@ -228,22 +228,24 @@ public abstract class BaseGLActivity extends Activity implements ActivityCompat. @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK) { - if (!JNIdc.guiIsOpen()) { - showMenu(); - return true; + if (event.getRepeatCount() == 0) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + if (!JNIdc.guiIsOpen()) { + showMenu(); + return true; + } + else if (JNIdc.guiIsContentBrowser()) { + finish(); + return true; + } } - else if (JNIdc.guiIsContentBrowser()) { - finish(); + if (InputDeviceManager.getInstance().joystickButtonEvent(event.getDeviceId(), keyCode, true)) return true; - } - } - if (InputDeviceManager.getInstance().joystickButtonEvent(event.getDeviceId(), keyCode, true)) - return true; - if (ViewConfiguration.get(this).hasPermanentMenuKey()) { - if (keyCode == KeyEvent.KEYCODE_MENU) { - return showMenu(); + if (ViewConfiguration.get(this).hasPermanentMenuKey()) { + if (keyCode == KeyEvent.KEYCODE_MENU) { + return showMenu(); + } } } return super.onKeyDown(keyCode, event); From b443fe9b255b07d0e0f590983c864e7baea9b1e4 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Fri, 5 Apr 2019 21:05:18 +0200 Subject: [PATCH 17/73] AUDIO: make the plugins self-registering No need anymore for the RegisterAllBackends() function and all plugins in one place. Use a static boolean to register every plugin by itself. --- core/oslib/audiobackend_alsa.cpp | 6 +- core/oslib/audiobackend_alsa.h | 4 -- core/oslib/audiobackend_android.h | 4 -- core/oslib/audiobackend_coreaudio.cpp | 47 ++++++------- core/oslib/audiobackend_coreaudio.h | 5 -- core/oslib/audiobackend_directsound.cpp | 46 ++++++------- core/oslib/audiobackend_directsound.h | 4 -- core/oslib/audiobackend_libao.cpp | 13 ++-- core/oslib/audiobackend_libao.h | 4 -- core/oslib/audiobackend_omx.cpp | 3 +- core/oslib/audiobackend_omx.h | 4 -- core/oslib/audiobackend_oss.cpp | 3 +- core/oslib/audiobackend_oss.h | 4 -- core/oslib/audiobackend_pulseaudio.cpp | 4 +- core/oslib/audiobackend_pulseaudio.h | 4 -- core/oslib/audiostream.cpp | 66 ++++++------------- .../reicast/src/main/jni/src/Android.cpp | 7 +- 17 files changed, 91 insertions(+), 137 deletions(-) delete mode 100644 core/oslib/audiobackend_alsa.h delete mode 100644 core/oslib/audiobackend_android.h delete mode 100644 core/oslib/audiobackend_coreaudio.h delete mode 100644 core/oslib/audiobackend_directsound.h delete mode 100644 core/oslib/audiobackend_libao.h delete mode 100644 core/oslib/audiobackend_omx.h delete mode 100644 core/oslib/audiobackend_oss.h delete mode 100644 core/oslib/audiobackend_pulseaudio.h diff --git a/core/oslib/audiobackend_alsa.cpp b/core/oslib/audiobackend_alsa.cpp index 949af077e..2ee230976 100644 --- a/core/oslib/audiobackend_alsa.cpp +++ b/core/oslib/audiobackend_alsa.cpp @@ -1,4 +1,4 @@ -#include "oslib/audiobackend_alsa.h" +#include "oslib/audiostream.h" #if USE_ALSA #include #include "cfg/cfg.h" @@ -175,11 +175,13 @@ static void alsa_term() snd_pcm_close(handle); } -audiobackend_t audiobackend_alsa = { +static audiobackend_t audiobackend_alsa = { "alsa", // Slug "Advanced Linux Sound Architecture", // Name &alsa_init, &alsa_push, &alsa_term }; + +static bool alsa = RegisterAudioBackend(&audiobackend_alsa); #endif diff --git a/core/oslib/audiobackend_alsa.h b/core/oslib/audiobackend_alsa.h deleted file mode 100644 index 3995cb1ac..000000000 --- a/core/oslib/audiobackend_alsa.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "oslib/audiostream.h" - -extern audiobackend_t audiobackend_alsa; diff --git a/core/oslib/audiobackend_android.h b/core/oslib/audiobackend_android.h deleted file mode 100644 index c2765c14b..000000000 --- a/core/oslib/audiobackend_android.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "oslib/audiostream.h" - -extern audiobackend_t audiobackend_android; \ No newline at end of file diff --git a/core/oslib/audiobackend_coreaudio.cpp b/core/oslib/audiobackend_coreaudio.cpp index 9ce685cd9..dd04926ce 100644 --- a/core/oslib/audiobackend_coreaudio.cpp +++ b/core/oslib/audiobackend_coreaudio.cpp @@ -1,18 +1,18 @@ /* Simple Core Audio backend for osx (and maybe ios?) Based off various audio core samples and dolphin's code - + This is part of the Reicast project, please consult the LICENSE file for licensing & related information - + This could do with some locking logic to avoid race conditions, and some variable length buffer logic to support chunk sizes other than 512 bytes - + It does work on my macmini though */ -#include "oslib/audiobackend_coreaudio.h" +#include "oslib/audiostream.h" #if HOST_OS == OS_DARWIN #include @@ -49,9 +49,9 @@ static OSStatus coreaudio_callback(void* ctx, AudioUnitRenderActionFlags* flags, samples_rptr = (samples_rptr + buf_size) % BUFSIZE; } } - + bufferEmpty.Set(); - + return noErr; } @@ -63,7 +63,7 @@ static void coreaudio_init() AudioStreamBasicDescription format; AudioComponentDescription desc; AudioComponent component; - + desc.componentType = kAudioUnitType_Output; #if !defined(TARGET_IPHONE) desc.componentSubType = kAudioUnitSubType_DefaultOutput; @@ -75,12 +75,12 @@ static void coreaudio_init() desc.componentFlagsMask = 0; desc.componentManufacturer = kAudioUnitManufacturer_Apple; component = AudioComponentFindNext(nullptr, &desc); - + verify(component != nullptr); - + err = AudioComponentInstanceNew(component, &audioUnit); verify(err == noErr); - + FillOutASBDForLPCM(format, 44100, 2, 16, 16, false, false, false); err = AudioUnitSetProperty(audioUnit, @@ -88,7 +88,7 @@ static void coreaudio_init() kAudioUnitScope_Input, 0, &format, sizeof(AudioStreamBasicDescription)); verify(err == noErr); - + callback_struct.inputProc = coreaudio_callback; callback_struct.inputProcRefCon = 0; err = AudioUnitSetProperty(audioUnit, @@ -96,24 +96,24 @@ static void coreaudio_init() kAudioUnitScope_Input, 0, &callback_struct, sizeof callback_struct); verify(err == noErr); - + /* err = AudioUnitSetParameter(audioUnit, kHALOutputParam_Volume, kAudioUnitParameterFlag_Output, 0, 1, 0); verify(err == noErr); - + */ - + err = AudioUnitInitialize(audioUnit); - + verify(err == noErr); - + err = AudioOutputUnitStart(audioUnit); verify(err == noErr); - + bufferEmpty.Set(); } @@ -134,23 +134,23 @@ static u32 coreaudio_push(void* frame, u32 samples, bool wait) samples_wptr = (samples_wptr + byte_size) % BUFSIZE; break; } - + return 1; } static void coreaudio_term() { OSStatus err; - + err = AudioOutputUnitStop(audioUnit); verify(err == noErr); - + err = AudioUnitUninitialize(audioUnit); verify(err == noErr); - + err = AudioComponentInstanceDispose(audioUnit); verify(err == noErr); - + bufferEmpty.Set(); } @@ -161,4 +161,7 @@ audiobackend_t audiobackend_coreaudio = { &coreaudio_push, &coreaudio_term }; + +static bool core = RegisterAudioBackend(&audiobackend_coreaudio); + #endif diff --git a/core/oslib/audiobackend_coreaudio.h b/core/oslib/audiobackend_coreaudio.h deleted file mode 100644 index 8f3172317..000000000 --- a/core/oslib/audiobackend_coreaudio.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include "oslib/audiostream.h" - -extern audiobackend_t audiobackend_coreaudio; - diff --git a/core/oslib/audiobackend_directsound.cpp b/core/oslib/audiobackend_directsound.cpp index 36a4d692c..d173e434b 100644 --- a/core/oslib/audiobackend_directsound.cpp +++ b/core/oslib/audiobackend_directsound.cpp @@ -1,4 +1,4 @@ -#include "oslib/audiobackend_directsound.h" +#include "oslib/audiostream.h" #if HOST_OS==OS_WINDOWS #include "oslib.h" #include @@ -19,31 +19,31 @@ static void directsound_init() verifyc(dsound->SetCooperativeLevel((HWND)libPvr_GetRenderTarget(),DSSCL_PRIORITY)); IDirectSoundBuffer* buffer_; - WAVEFORMATEX wfx; - DSBUFFERDESC desc; + WAVEFORMATEX wfx; + DSBUFFERDESC desc; - // Set up WAV format structure. + // Set up WAV format structure. - memset(&wfx, 0, sizeof(WAVEFORMATEX)); - wfx.wFormatTag = WAVE_FORMAT_PCM; - wfx.nChannels = 2; - wfx.nSamplesPerSec = 44100; - wfx.nBlockAlign = 4; - wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; - wfx.wBitsPerSample = 16; + memset(&wfx, 0, sizeof(WAVEFORMATEX)); + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.nBlockAlign = 4; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + wfx.wBitsPerSample = 16; - // Set up DSBUFFERDESC structure. + // Set up DSBUFFERDESC structure. ds_ring_size=8192*wfx.nBlockAlign; - memset(&desc, 0, sizeof(DSBUFFERDESC)); - desc.dwSize = sizeof(DSBUFFERDESC); - desc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY;// _CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; - - desc.dwBufferBytes = ds_ring_size; - desc.lpwfxFormat = &wfx; + memset(&desc, 0, sizeof(DSBUFFERDESC)); + desc.dwSize = sizeof(DSBUFFERDESC); + desc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY;// _CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; + + desc.dwBufferBytes = ds_ring_size; + desc.lpwfxFormat = &wfx; + - if (settings.aica.HW_mixing==0) { @@ -71,7 +71,7 @@ static void directsound_init() //Play the buffer ! verifyc(buffer->Play(0,0,DSBPLAY_LOOPING)); - + } @@ -159,7 +159,7 @@ static u32 directsound_push(void* frame, u32 samples, bool wait) wait &= w; */ int ffs=1; - + /* while (directsound_IsAudioBufferedLots() && wait) if (ffs == 0) @@ -175,7 +175,7 @@ static u32 directsound_push(void* frame, u32 samples, bool wait) static void directsound_term() { buffer->Stop(); - + buffer->Release(); dsound->Release(); } @@ -187,4 +187,6 @@ audiobackend_t audiobackend_directsound = { &directsound_push, &directsound_term }; + +static bool ds = RegisterAudioBackend(&audiobackend_directsound); #endif diff --git a/core/oslib/audiobackend_directsound.h b/core/oslib/audiobackend_directsound.h deleted file mode 100644 index 544ba629d..000000000 --- a/core/oslib/audiobackend_directsound.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "oslib/audiostream.h" - -extern audiobackend_t audiobackend_directsound; diff --git a/core/oslib/audiobackend_libao.cpp b/core/oslib/audiobackend_libao.cpp index 1445c1492..c235dca00 100644 --- a/core/oslib/audiobackend_libao.cpp +++ b/core/oslib/audiobackend_libao.cpp @@ -1,4 +1,4 @@ -#include "oslib/audiobackend_libao.h" +#include "oslib/audiostream.h" #ifdef USE_LIBAO #include @@ -10,12 +10,12 @@ static void libao_init() { ao_initialize(); memset(&aoformat, 0, sizeof(aoformat)); - + aoformat.bits = 16; aoformat.channels = 2; aoformat.rate = 44100; aoformat.byte_format = AO_FMT_LITTLE; - + aodevice = ao_open_live(ao_default_driver_id(), &aoformat, NULL); // Live output if (!aodevice) aodevice = ao_open_live(ao_driver_id("null"), &aoformat, NULL); @@ -23,13 +23,13 @@ static void libao_init() static u32 libao_push(void* frame, u32 samples, bool wait) { - if (aodevice) + if (aodevice) ao_play(aodevice, (char*)frame, samples * 4); - + return 1; } -static void libao_term() +static void libao_term() { if (aodevice) { @@ -46,4 +46,5 @@ audiobackend_t audiobackend_libao = { &libao_term }; +static bool ao = RegisterAudioBackend(&audiobackend_libao); #endif diff --git a/core/oslib/audiobackend_libao.h b/core/oslib/audiobackend_libao.h deleted file mode 100644 index 5bf957286..000000000 --- a/core/oslib/audiobackend_libao.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "oslib/audiostream.h" - -extern audiobackend_t audiobackend_libao; diff --git a/core/oslib/audiobackend_omx.cpp b/core/oslib/audiobackend_omx.cpp index ffb0779a9..71c426b68 100644 --- a/core/oslib/audiobackend_omx.cpp +++ b/core/oslib/audiobackend_omx.cpp @@ -1,4 +1,4 @@ -#include "oslib/audiobackend_omx.h" +#include "oslib/audiostream.h" #if USE_OMX #include @@ -316,4 +316,5 @@ audiobackend_t audiobackend_omx = { &omx_term }; +static bool omx = RegisterAudioBackend(&audiobackend_omx); #endif diff --git a/core/oslib/audiobackend_omx.h b/core/oslib/audiobackend_omx.h deleted file mode 100644 index 63fdcb5fd..000000000 --- a/core/oslib/audiobackend_omx.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "oslib/audiostream.h" - -extern audiobackend_t audiobackend_omx; diff --git a/core/oslib/audiobackend_oss.cpp b/core/oslib/audiobackend_oss.cpp index 67015db6c..cc653466f 100644 --- a/core/oslib/audiobackend_oss.cpp +++ b/core/oslib/audiobackend_oss.cpp @@ -1,4 +1,4 @@ -#include "oslib/audiobackend_oss.h" +#include "oslib/audiostream.h" #ifdef USE_OSS #include #include @@ -51,4 +51,5 @@ audiobackend_t audiobackend_oss = { &oss_term }; +static bool oss = RegisterAudioBackend(&audiobackend_oss); #endif diff --git a/core/oslib/audiobackend_oss.h b/core/oslib/audiobackend_oss.h deleted file mode 100644 index cfeb53955..000000000 --- a/core/oslib/audiobackend_oss.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "oslib/audiostream.h" - -extern audiobackend_t audiobackend_oss; diff --git a/core/oslib/audiobackend_pulseaudio.cpp b/core/oslib/audiobackend_pulseaudio.cpp index dea4256cc..28963b00a 100644 --- a/core/oslib/audiobackend_pulseaudio.cpp +++ b/core/oslib/audiobackend_pulseaudio.cpp @@ -1,4 +1,4 @@ -#include "oslib/audiobackend_pulseaudio.h" +#include "oslib/audiostream.h" #ifdef USE_PULSEAUDIO #include #include @@ -45,4 +45,6 @@ audiobackend_t audiobackend_pulseaudio = { &pulseaudio_push, &pulseaudio_term }; + +static bool pulse = RegisterAudioBackend(&audiobackend_pulseaudio); #endif diff --git a/core/oslib/audiobackend_pulseaudio.h b/core/oslib/audiobackend_pulseaudio.h deleted file mode 100644 index 7948d5b16..000000000 --- a/core/oslib/audiobackend_pulseaudio.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "oslib/audiostream.h" - -extern audiobackend_t audiobackend_pulseaudio; diff --git a/core/oslib/audiostream.cpp b/core/oslib/audiostream.cpp index f89e783fb..8cc617e3e 100644 --- a/core/oslib/audiostream.cpp +++ b/core/oslib/audiostream.cpp @@ -2,14 +2,6 @@ #include "cfg/cfg.h" #include "oslib/oslib.h" #include "audiostream.h" -#include "oslib/audiobackend_directsound.h" -#include "oslib/audiobackend_android.h" -#include "oslib/audiobackend_alsa.h" -#include "oslib/audiobackend_oss.h" -#include "oslib/audiobackend_pulseaudio.h" -#include "oslib/audiobackend_coreaudio.h" -#include "oslib/audiobackend_omx.h" -#include "oslib/audiobackend_libao.h" struct SoundFrame { s16 l;s16 r; }; #define SAMPLE_COUNT 512 @@ -25,18 +17,20 @@ u32 gen_samples=0; double time_diff = 128/44100.0; double time_last; + #ifdef LOG_SOUND +// TODO Only works on Windows! WaveWriter rawout("d:\\aica_out.wav"); #endif -static bool audiobackends_registered = false; static unsigned int audiobackends_num_max = 1; static unsigned int audiobackends_num_registered = 0; -static audiobackend_t **audiobackends = static_cast(calloc(audiobackends_num_max, sizeof(audiobackend_t*))); +static audiobackend_t **audiobackends = NULL; static audiobackend_t *audiobackend_current = NULL; bool RegisterAudioBackend(audiobackend_t *backend) { + printf("RegisterAUdio!\n"); /* This function announces the availability of an audio backend to reicast. */ // Check if backend is valid if (backend == NULL) @@ -44,10 +38,16 @@ bool RegisterAudioBackend(audiobackend_t *backend) printf("ERROR: Tried to register invalid audio backend (NULL pointer).\n"); return false; } + if (backend->slug == "auto" || backend->slug == "none") { printf("ERROR: Tried to register invalid audio backend (slug \"%s\" is a reserved keyword).\n", backend->slug.c_str()); return false; } + + // First call to RegisterAudioBackend(), create the backend structure; + if (audiobackends == NULL) + audiobackends = static_cast(calloc(audiobackends_num_max, sizeof(audiobackend_t*))); + // Check if we need to allocate addition memory for storing the pointers and allocate if neccessary if (audiobackends_num_registered == audiobackends_num_max) { @@ -67,46 +67,20 @@ bool RegisterAudioBackend(audiobackend_t *backend) } audiobackends = new_ptr; } + audiobackends[audiobackends_num_registered] = backend; audiobackends_num_registered++; return true; } -void RegisterAllAudioBackends() { - #if HOST_OS==OS_WINDOWS - RegisterAudioBackend(&audiobackend_directsound); - #endif - #if ANDROID - RegisterAudioBackend(&audiobackend_android); - #endif - #if USE_OMX - RegisterAudioBackend(&audiobackend_omx); - #endif - #if USE_ALSA - RegisterAudioBackend(&audiobackend_alsa); - #endif - #if USE_OSS - RegisterAudioBackend(&audiobackend_oss); - #endif - #if USE_PULSEAUDIO - RegisterAudioBackend(&audiobackend_pulseaudio); - #endif - #if USE_LIBAO - RegisterAudioBackend(&audiobackend_libao); - #endif - #if HOST_OS == OS_DARWIN - RegisterAudioBackend(&audiobackend_coreaudio); - #endif - audiobackends_registered = true; -} - static audiobackend_t* GetAudioBackend(std::string slug) { + printf("AudioBackend: %s\n", slug); if (slug == "none") { printf("WARNING: Audio backend set to \"none\"!\n"); } - else if(audiobackends_num_registered > 0) + else if (audiobackends_num_registered > 0) { if (slug == "auto") { @@ -135,7 +109,8 @@ static audiobackend_t* GetAudioBackend(std::string slug) return NULL; } -u32 PushAudio(void* frame, u32 amt, bool wait) { +u32 PushAudio(void* frame, u32 amt, bool wait) +{ if (audiobackend_current != NULL) { return audiobackend_current->push(frame, amt, wait); } @@ -151,6 +126,7 @@ u32 asRingUsedCount() //s32 sz=(WritePtr+1)%RingBufferSampleCount-ReadPtr; //return sz<0?sz+RingBufferSampleCount:sz; } + u32 asRingFreeCount() { return RingBufferSampleCount-asRingUsedCount(); @@ -178,11 +154,6 @@ void InitAudio() cfgSaveInt("audio","disable",0); - if (!audiobackends_registered) { - //FIXME: There might some nicer way to do this. - RegisterAllAudioBackends(); - } - if (audiobackend_current != NULL) { printf("ERROR: The audio backend \"%s\" (%s) has already been initialized, you need to terminate it before you can call audio_init() again!\n", audiobackend_current->slug.c_str(), audiobackend_current->name.c_str()); return; @@ -194,8 +165,9 @@ void InitAudio() printf("WARNING: Running without audio!\n"); return; } + printf("Initializing audio backend \"%s\" (%s)...\n", audiobackend_current->slug.c_str(), audiobackend_current->name.c_str()); - audiobackend_current->init(); + audiobackend_current->init(); } void TermAudio() @@ -204,5 +176,5 @@ void TermAudio() audiobackend_current->term(); printf("Terminating audio backend \"%s\" (%s)...\n", audiobackend_current->slug.c_str(), audiobackend_current->name.c_str()); audiobackend_current = NULL; - } + } } diff --git a/shell/android-studio/reicast/src/main/jni/src/Android.cpp b/shell/android-studio/reicast/src/main/jni/src/Android.cpp index 3ab96e5dd..fad20b5e7 100644 --- a/shell/android-studio/reicast/src/main/jni/src/Android.cpp +++ b/shell/android-studio/reicast/src/main/jni/src/Android.cpp @@ -20,7 +20,7 @@ #include "hw/maple/maple_devs.h" #include "hw/maple/maple_if.h" #include "hw/naomi/naomi_cart.h" -#include "oslib/audiobackend_android.h" +#include "oslib/audiostream.h" #include "imgread/common.h" #include "rend/gui.h" #include "cfg/cfg.h" @@ -529,6 +529,9 @@ audiobackend_t audiobackend_android = { &androidaudio_term }; +static bool android = RegisterAudioBackend(&audiobackend_android); + + JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_AudioBackend_setInstance(JNIEnv *env, jobject obj, jobject instance) { if (g_audioBackend != NULL) @@ -568,7 +571,7 @@ void os_DebugBreak() raise(SIGABRT); //pthread_exit(NULL); - + // Attach debugger here to figure out what went wrong for(;;) ; } From b8ae61bc5c8fbcc0c16beac37122b970473ebdd4 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Fri, 5 Apr 2019 21:14:42 +0200 Subject: [PATCH 18/73] AUDIO: Sort audio plugins by name --- core/oslib/audiostream.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/oslib/audiostream.cpp b/core/oslib/audiostream.cpp index 8cc617e3e..6149ea902 100644 --- a/core/oslib/audiostream.cpp +++ b/core/oslib/audiostream.cpp @@ -145,6 +145,27 @@ void WriteSample(s16 r, s16 l) } } +static bool backends_sorted = false; +void SortBackends() +{ + if (backends_sorted) + return; + + // Sort backends by slug + for (int n = audiobackends_num_registered; n > 0; n--) + { + for (int i = 0; i < n-1; i++) + { + if (audiobackends[i]->slug > audiobackends[i+1]->slug) + { + audiobackend_t* swap = audiobackends[i]; + audiobackends[i] = audiobackends[i+1]; + audiobackends[i+1] = swap; + } + } + } +} + void InitAudio() { if (cfgLoadInt("audio", "disable", 0)) { @@ -152,13 +173,15 @@ void InitAudio() return; } - cfgSaveInt("audio","disable",0); + cfgSaveInt("audio", "disable", 0); if (audiobackend_current != NULL) { printf("ERROR: The audio backend \"%s\" (%s) has already been initialized, you need to terminate it before you can call audio_init() again!\n", audiobackend_current->slug.c_str(), audiobackend_current->name.c_str()); return; } + SortBackends(); + string audiobackend_slug = cfgLoadStr("audio", "backend", "auto"); // FIXME: This could be made a parameter audiobackend_current = GetAudioBackend(audiobackend_slug); if (audiobackend_current == NULL) { From 16f9200bfa36917f6b749c79973acf0d592c2144 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Fri, 5 Apr 2019 22:22:46 +0200 Subject: [PATCH 19/73] AUDIO: Allow selection of backend --- core/nullDC.cpp | 8 +++++-- core/oslib/audiostream.cpp | 20 +++++++++++------ core/oslib/audiostream.h | 6 ++++++ core/rend/gui.cpp | 44 ++++++++++++++++++++++++++++++++++++++ core/types.h | 41 +++++++++++++++++++---------------- 5 files changed, 92 insertions(+), 27 deletions(-) diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 89c637803..fc44f3a3e 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -134,7 +134,7 @@ void LoadSpecialSettings() safemode_game = false; tr_poly_depth_mask_game = false; extra_depth_game = false; - + if (reios_windows_ce) { printf("Enabling Extra depth scaling for Windows CE games\n"); @@ -190,7 +190,7 @@ void LoadSpecialSettings() } #elif DC_PLATFORM == DC_PLATFORM_NAOMI || DC_PLATFORM == DC_PLATFORM_ATOMISWAVE printf("Game ID is [%s]\n", naomi_game_id); - + if (!strcmp("METAL SLUG 6", naomi_game_id) || !strcmp("WAVE RUNNER GP", naomi_game_id)) { printf("Enabling Dynarec safe mode for game %s\n", naomi_game_id); @@ -499,6 +499,7 @@ void InitSettings() settings.aica.LimitFPS = true; settings.aica.NoBatch = false; // This also controls the DSP. Disabled by default settings.aica.NoSound = false; + settings.audio.backend = "auto"; settings.rend.UseMipmaps = true; settings.rend.WideScreen = false; settings.rend.ShowFPS = false; @@ -560,6 +561,7 @@ void LoadSettings(bool game_specific) { const char *config_section = game_specific ? cfgGetGameId() : "config"; const char *input_section = game_specific ? cfgGetGameId() : "input"; + const char *audio_section = game_specific ? cfgGetGameId() : "audio"; settings.dynarec.Enable = cfgLoadBool(config_section, "Dynarec.Enabled", settings.dynarec.Enable); settings.dynarec.idleskip = cfgLoadBool(config_section, "Dynarec.idleskip", settings.dynarec.idleskip); @@ -575,6 +577,7 @@ void LoadSettings(bool game_specific) settings.aica.LimitFPS = cfgLoadBool(config_section, "aica.LimitFPS", settings.aica.LimitFPS); settings.aica.NoBatch = cfgLoadBool(config_section, "aica.NoBatch", settings.aica.NoBatch); settings.aica.NoSound = cfgLoadBool(config_section, "aica.NoSound", settings.aica.NoSound); + settings.audio.backend = cfgLoadStr(audio_section, "backend", settings.audio.backend.c_str()); settings.rend.UseMipmaps = cfgLoadBool(config_section, "rend.UseMipmaps", settings.rend.UseMipmaps); settings.rend.WideScreen = cfgLoadBool(config_section, "rend.WideScreen", settings.rend.WideScreen); settings.rend.ShowFPS = cfgLoadBool(config_section, "rend.ShowFPS", settings.rend.ShowFPS); @@ -708,6 +711,7 @@ void SaveSettings() cfgSaveBool("config", "aica.LimitFPS", settings.aica.LimitFPS); cfgSaveBool("config", "aica.NoBatch", settings.aica.NoBatch); cfgSaveBool("config", "aica.NoSound", settings.aica.NoSound); + cfgSaveStr("audio", "backend", settings.audio.backend.c_str()); cfgSaveBool("config", "rend.WideScreen", settings.rend.WideScreen); cfgSaveBool("config", "rend.ShowFPS", settings.rend.ShowFPS); if (!rtt_to_buffer_game || !settings.rend.RenderToTextureBuffer) diff --git a/core/oslib/audiostream.cpp b/core/oslib/audiostream.cpp index 6149ea902..ea6845bed 100644 --- a/core/oslib/audiostream.cpp +++ b/core/oslib/audiostream.cpp @@ -28,9 +28,18 @@ static unsigned int audiobackends_num_registered = 0; static audiobackend_t **audiobackends = NULL; static audiobackend_t *audiobackend_current = NULL; +u32 GetAudioBackendCount() +{ + return audiobackends_num_registered; +} + +audiobackend_t* GetAudioBackend(int num) +{ + return audiobackends[num]; +} + bool RegisterAudioBackend(audiobackend_t *backend) { - printf("RegisterAUdio!\n"); /* This function announces the availability of an audio backend to reicast. */ // Check if backend is valid if (backend == NULL) @@ -73,9 +82,8 @@ bool RegisterAudioBackend(audiobackend_t *backend) return true; } -static audiobackend_t* GetAudioBackend(std::string slug) +audiobackend_t* GetAudioBackend(std::string slug) { - printf("AudioBackend: %s\n", slug); if (slug == "none") { printf("WARNING: Audio backend set to \"none\"!\n"); @@ -146,7 +154,7 @@ void WriteSample(s16 r, s16 l) } static bool backends_sorted = false; -void SortBackends() +void SortAudioBackends() { if (backends_sorted) return; @@ -180,9 +188,9 @@ void InitAudio() return; } - SortBackends(); + SortAudioBackends(); - string audiobackend_slug = cfgLoadStr("audio", "backend", "auto"); // FIXME: This could be made a parameter + string audiobackend_slug = settings.audio.backend; audiobackend_current = GetAudioBackend(audiobackend_slug); if (audiobackend_current == NULL) { printf("WARNING: Running without audio!\n"); diff --git a/core/oslib/audiostream.h b/core/oslib/audiostream.h index b700eb066..2726db0e1 100644 --- a/core/oslib/audiostream.h +++ b/core/oslib/audiostream.h @@ -1,5 +1,6 @@ #pragma once #include "types.h" +#include //Get used size in the ring buffer u32 asRingUsedCount(); @@ -24,3 +25,8 @@ extern bool RegisterAudioBackend(audiobackend_t* backend); extern void InitAudio(); extern u32 PushAudio(void* frame, u32 amt, bool wait); extern void TermAudio(); + +u32 GetAudioBackendCount(); +void SortAudioBackends(); +audiobackend_t* GetAudioBackend(int num); +audiobackend_t* GetAudioBackend(std::string slug); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index cfc134cbc..2db5ea336 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -35,6 +35,8 @@ #include "gui_util.h" #include "gui_android.h" #include "version/version.h" +#include "oslib/audiostream.h" + extern void dc_loadstate(); extern void dc_savestate(); @@ -989,6 +991,48 @@ static void gui_display_settings() ImGui::Checkbox("Disable Sound", &settings.aica.NoSound); ImGui::SameLine(); ShowHelpMarker("Disable the emulator sound output"); + + audiobackend_t* backend = NULL;; + std::string backend_name = settings.audio.backend; + if (backend_name != "auto" && backend_name != "none") + { + backend = GetAudioBackend(settings.audio.backend); + if (backend != NULL) + backend_name = backend->slug; + } + + SortAudioBackends(); + if (ImGui::BeginCombo("Audio Backend", backend_name.c_str(), ImGuiComboFlags_None)) + { + bool is_selected = (settings.audio.backend == "auto"); + if (ImGui::Selectable("auto", &is_selected)) + settings.audio.backend = "auto"; + ImGui::SameLine(); ImGui::Text("-"); + ImGui::SameLine(); ImGui::Text("Autoselect audio backend"); + + is_selected = (settings.audio.backend == "none"); + if (ImGui::Selectable("none", &is_selected)) + settings.audio.backend = "none"; + ImGui::SameLine(); ImGui::Text("-"); + ImGui::SameLine(); ImGui::Text("No audio backend"); + + for (int i = 0; i < GetAudioBackendCount(); i++) + { + audiobackend_t* backend = GetAudioBackend(i); + is_selected = (settings.audio.backend == backend->slug); + + if (ImGui::Selectable(backend->slug.c_str(), &is_selected)) + settings.audio.backend = backend->slug; + ImGui::SameLine(); ImGui::Text("-"); + ImGui::SameLine(); ImGui::Text(backend->name.c_str()); + if (is_selected) + ImGui::SetItemDefaultFocus(); + } + ImGui::EndCombo(); + } + ImGui::SameLine(); + ShowHelpMarker("The audio backend to use"); + ImGui::Checkbox("Enable DSP", &settings.aica.NoBatch); ImGui::SameLine(); ShowHelpMarker("Enable the Dreamcast Digital Sound Processor. Only recommended on fast and arm64 platforms"); diff --git a/core/types.h b/core/types.h index a9a835ac1..4769c6e48 100644 --- a/core/types.h +++ b/core/types.h @@ -39,7 +39,7 @@ #undef _CRT_SECURE_NO_DEPRECATE #endif -#define _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE //unnamed struncts/unions #pragma warning( disable : 4201) @@ -123,7 +123,7 @@ enum HollyInterruptType }; enum HollyInterruptID -{ +{ // asic9a /sh4 external holly normal [internal] holly_RENDER_DONE_vd = holly_nrm | 0, //bit 0 = End of Render interrupt : Video holly_RENDER_DONE_isp = holly_nrm | 1, //bit 1 = End of Render interrupt : ISP @@ -132,11 +132,11 @@ enum HollyInterruptID holly_SCANINT1 = holly_nrm | 3, //bit 3 = V Blank-in interrupt holly_SCANINT2 = holly_nrm | 4, //bit 4 = V Blank-out interrupt holly_HBLank = holly_nrm | 5, //bit 5 = H Blank-in interrupt - + holly_YUV_DMA = holly_nrm | 6, //bit 6 = End of Transferring interrupt : YUV holly_OPAQUE = holly_nrm | 7, //bit 7 = End of Transferring interrupt : Opaque List holly_OPAQUEMOD = holly_nrm | 8, //bit 8 = End of Transferring interrupt : Opaque Modifier Volume List - + holly_TRANS = holly_nrm | 9, //bit 9 = End of Transferring interrupt : Translucent List holly_TRANSMOD = holly_nrm | 10, //bit 10 = End of Transferring interrupt : Translucent Modifier Volume List holly_PVR_DMA = holly_nrm | 11, //bit 11 = End of DMA interrupt : PVR-DMA @@ -145,12 +145,12 @@ enum HollyInterruptID holly_MAPLE_VBOI = holly_nrm | 13, //bit 13 = Maple V blank over interrupt holly_GDROM_DMA = holly_nrm | 14, //bit 14 = End of DMA interrupt : GD-DMA holly_SPU_DMA = holly_nrm | 15, //bit 15 = End of DMA interrupt : AICA-DMA - + holly_EXT_DMA1 = holly_nrm | 16, //bit 16 = End of DMA interrupt : Ext-DMA1(External 1) holly_EXT_DMA2 = holly_nrm | 17, //bit 17 = End of DMA interrupt : Ext-DMA2(External 2) holly_DEV_DMA = holly_nrm | 18, //bit 18 = End of DMA interrupt : Dev-DMA(Development tool DMA) - - holly_CH2_DMA = holly_nrm | 19, //bit 19 = End of DMA interrupt : ch2-DMA + + holly_CH2_DMA = holly_nrm | 19, //bit 19 = End of DMA interrupt : ch2-DMA holly_PVR_SortDMA = holly_nrm | 20, //bit 20 = End of DMA interrupt : Sort-DMA (Transferring for alpha sorting) holly_PUNCHTHRU = holly_nrm | 21, //bit 21 = End of Transferring interrupt : Punch Through List @@ -188,8 +188,8 @@ enum HollyInterruptID //bit 23 = G2 : AICA-DMA Time out //bit 24 = G2 : Ext-DMA1 Time out //bit 25 = G2 : Ext-DMA2 Time out - //bit 26 = G2 : Dev-DMA Time out - //bit 27 = G2 : Time out in CPU accessing + //bit 26 = G2 : Dev-DMA Time out + //bit 27 = G2 : Time out in CPU accessing }; @@ -200,7 +200,7 @@ struct vram_block u32 end; u32 len; u32 type; - + void* userdata; }; @@ -229,7 +229,7 @@ struct NDC_WINDOW_RECT //****************************************************** //*********************** PowerVR ********************** //****************************************************** - + void libCore_vramlock_Unlock_block (vram_block* block); void libCore_vramlock_Unlock_block_wb (vram_block* block); vram_block* libCore_vramlock_Lock(u32 start_offset,u32 end_offset,void* userdata); @@ -246,7 +246,7 @@ enum DiscType CdRom_XA=0x20, CdRom_Extra=0x30, CdRom_CDI=0x40, - GdRom=0x80, + GdRom=0x80, NoDisk=0x1, //These are a bit hacky .. but work for now ... Open=0x2, //tray is open :) @@ -576,7 +576,7 @@ enum RegIO RIO_RO = REG_RO | REG_WF, RIO_RO_FUNC = REG_RO | REG_RF | REG_WF, RIO_CONST = REG_RO | REG_WF, - RIO_WO_FUNC = REG_WF | REG_RF | REG_WO, + RIO_WO_FUNC = REG_WF | REG_RF | REG_WO, RIO_NO_ACCESS = REG_WF | REG_RF | REG_NO_ACCESS }; @@ -645,7 +645,7 @@ struct settings_t bool disable_nvmem; SmcCheckEnum SmcCheckLevel; } dynarec; - + struct { u32 run_counts; @@ -677,6 +677,9 @@ struct settings_t bool NoSound; } aica; + struct{ + std::string backend; + } audio; #if USE_OMX struct { @@ -706,7 +709,7 @@ struct settings_t { u32 ta_skip; u32 rend; - + u32 MaxThreads; bool SynchronousRender; } pvr; @@ -749,7 +752,7 @@ static inline void do_nada(...) { } #ifdef _ANDROID #include -#ifdef printf +#ifdef printf #undef printf #endif @@ -856,7 +859,7 @@ void libARM_Update(u32 cycles); else if (sz==2) \ return *(u16*)&arr[addr]; \ else if (sz==4) \ - return *(u32*)&arr[addr];} + return *(u32*)&arr[addr];} #define WriteMemArr(arr,addr,data,sz) \ {if(sz==1) \ @@ -864,7 +867,7 @@ void libARM_Update(u32 cycles); else if (sz==2) \ {*(u16*)&arr[addr]=(u16)data;} \ else if (sz==4) \ - {*(u32*)&arr[addr]=data;}} + {*(u32*)&arr[addr]=data;}} #define WriteMemArrRet(arr,addr,data,sz) \ {if(sz==1) \ @@ -872,7 +875,7 @@ void libARM_Update(u32 cycles); else if (sz==2) \ {*(u16*)&arr[addr]=(u16)data;return;} \ else if (sz==4) \ - {*(u32*)&arr[addr]=data;return;}} + {*(u32*)&arr[addr]=data;return;}} struct OnLoad { From e8205e568b2c9057fd321e0f18bf69b1e83c4670 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sat, 6 Apr 2019 19:36:57 +0200 Subject: [PATCH 20/73] naomi/aw: fix atomiswave and naomi inputs atomiswave analog axes support map atomiswave and naomi driving games inputs --- core/hw/maple/maple_cfg.cpp | 68 +++++++++++-- core/hw/maple/maple_cfg.h | 2 + core/hw/maple/maple_devs.cpp | 186 ++++++++++++++++++++++------------- core/hw/naomi/naomi.cpp | 11 ++- core/hw/naomi/naomi_cart.cpp | 4 +- core/hw/naomi/naomi_cart.h | 2 +- core/linux-dist/x11.cpp | 12 --- core/windows/winmain.cpp | 8 -- 8 files changed, 187 insertions(+), 106 deletions(-) diff --git a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp index 5a02ef11b..f14562411 100644 --- a/core/hw/maple/maple_cfg.cpp +++ b/core/hw/maple/maple_cfg.cpp @@ -4,6 +4,7 @@ #include "maple_devs.h" #include "maple_cfg.h" #include "cfg/cfg.h" +#include "hw/naomi/naomi_cart.h" #define HAS_VMU /* @@ -28,13 +29,31 @@ extern u16 kcode[4]; extern u32 vks[4]; extern s8 joyx[4],joyy[4]; extern u8 rt[4],lt[4]; -extern bool naomi_test_button; u8 GetBtFromSgn(s8 val) { return val+128; } +u32 awave_button_mapping[] = { + AWAVE_SERVICE_KEY, // DC_BTN_C + AWAVE_BTN1_KEY, // DC_BTN_B + AWAVE_BTN0_KEY, // DC_BTN_A + AWAVE_START_KEY, // DC_BTN_START + AWAVE_UP_KEY, // DC_DPAD_UP + AWAVE_DOWN_KEY, // DC_DPAD_DOWN + AWAVE_LEFT_KEY, // DC_DPAD_LEFT + AWAVE_RIGHT_KEY, // DC_DPAD_RIGHT + AWAVE_TEST_KEY, // DC_BTN_Z + AWAVE_BTN3_KEY, // DC_BTN_Y + AWAVE_BTN2_KEY, // DC_BTN_X + AWAVE_COIN_KEY, // DC_BTN_D + // DC_DPAD2_UP + // DC_DPAD2_DOWN + // DC_DPAD2_LEFT + // DC_DPAD2_RIGHT +}; + struct MapleConfigMap : IMapleConfigMap { maple_device* dev; @@ -59,17 +78,32 @@ struct MapleConfigMap : IMapleConfigMap pjs->kcode=kcode[player_num]; #if DC_PLATFORM == DC_PLATFORM_DREAMCAST - pjs->kcode |= 0xF901; -#elif DC_PLATFORM == DC_PLATFORM_ATOMISWAVE - if (naomi_test_button) - pjs->kcode &= ~(1 << 14); -// if (!(pjs->kcode & (1 << 9))) // Hack (Y -> service btn) -// pjs->kcode &= ~(1 << 13); -#endif + pjs->kcode |= 0xF901; // mask off DPad2, C, D and Z pjs->joy[PJAI_X1]=GetBtFromSgn(joyx[player_num]); pjs->joy[PJAI_Y1]=GetBtFromSgn(joyy[player_num]); pjs->trigger[PJTI_R]=rt[player_num]; pjs->trigger[PJTI_L]=lt[player_num]; +#elif DC_PLATFORM == DC_PLATFORM_ATOMISWAVE + pjs->kcode = 0xFFFF; + for (int i = 0; i < 16; i++) + { + if ((kcode[player_num] & (1 << i)) == 0) + pjs->kcode &= ~awave_button_mapping[i]; + } + pjs->joy[PJAI_X1] = GetBtFromSgn(joyx[player_num]); + if (NaomiGameInputs != NULL && NaomiGameInputs->axes[1].name != NULL && NaomiGameInputs->axes[1].type == Half) + { + // Driving games: put axis 2 on RT (accel) and axis 3 on LT (brake) + pjs->joy[PJAI_Y1] = rt[player_num]; + pjs->joy[PJAI_X2] = lt[player_num]; + } + else + { + pjs->joy[PJAI_Y1] = GetBtFromSgn(joyy[player_num]); + pjs->joy[PJAI_X2] = rt[player_num]; + pjs->joy[PJAI_Y2] = lt[player_num]; + } +#endif } void SetImage(void* img) { @@ -77,6 +111,16 @@ struct MapleConfigMap : IMapleConfigMap } }; +bool maple_atomiswave_coin_chute(int slot) +{ + for (int i = 0; i < 16; i++) + { + if (awave_button_mapping[i] == AWAVE_COIN_KEY && (kcode[slot] & (1 << i)) == 0) + return true; + } + return false; +} + void mcfg_Create(MapleDeviceType type, u32 bus, u32 port, s32 player_num = -1) { if (MapleDevices[bus][port] != NULL) @@ -100,8 +144,12 @@ void mcfg_CreateAtomisWaveControllers() // Then other devices on port 2 and 3 for analog axes, light guns, ... mcfg_Create(MDT_SegaController, 0, 5); mcfg_Create(MDT_SegaController, 1, 5); -// mcfg_Create(MDT_SegaController, 2, 5, 0); -// mcfg_Create(MDT_SegaController, 3, 5, 1); + if (NaomiGameInputs != NULL && NaomiGameInputs->axes[0].name != NULL) + { + // Game needs analog axes + mcfg_Create(MDT_SegaController, 2, 5, 0); + mcfg_Create(MDT_SegaController, 3, 5, 1); + } // mcfg_Create(MDT_LightGun, 2, 5, 0); // mcfg_Create(MDT_LightGun, 3, 5, 1); // mcfg_Create(MDT_Mouse, 2, 5, 0); diff --git a/core/hw/maple/maple_cfg.h b/core/hw/maple/maple_cfg.h index 4afcc99ce..75d4d116e 100644 --- a/core/hw/maple/maple_cfg.h +++ b/core/hw/maple/maple_cfg.h @@ -68,3 +68,5 @@ void mcfg_CreateAtomisWaveControllers(); void mcfg_DestroyDevices(); void mcfg_SerializeDevices(void **data, unsigned int *total_size); void mcfg_UnserializeDevices(void **data, unsigned int *total_size); + +bool maple_atomiswave_coin_chute(int slot); diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index ef9d5ac35..a26a3f01a 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -7,6 +7,7 @@ #include "hw/naomi/naomi.h" #include "hw/naomi/naomi_cart.h" #include "hw/pvr/spg.h" +#include "input/gamepad.h" #include #include "deps/zlib/zlib.h" @@ -215,7 +216,12 @@ struct maple_sega_controller: maple_base //struct data //3*4 - w32( 0xfe060f00); +#if DC_PLATFORM != DC_PLATFORM_ATOMISWAVE + w32(0xfe060f00); +#else + // More buttons, more digital axes + w32(0xff663f00); +#endif w32( 0); w32( 0); @@ -248,6 +254,7 @@ struct maple_sega_controller: maple_base //4 w32(MFID_0_Input); +#if DC_PLATFORM != DC_PLATFORM_ATOMISWAVE //state data //2 key code w16(pjs.kcode); @@ -270,6 +277,31 @@ struct maple_sega_controller: maple_base w8(0x80); //1 w8(0x80); +#else + //state data + //2 key code + w16(pjs.kcode | AWAVE_TRIGGER_KEY); + + //not used + //1 + w8(0); + //1 + w8(0); + + //joyx + //1 + w8(pjs.joy[PJAI_X1]); + //joyy + //1 + w8(pjs.joy[PJAI_Y1]); + + //joyrx + //1 + w8(pjs.joy[PJAI_X2]); + //joyry + //1 + w8(pjs.joy[PJAI_Y2]); +#endif } return MDRS_DataTransfer; @@ -1381,20 +1413,29 @@ static u16 getRightTriggerAxis() return rt[0] << 8; } -NaomiInputMapping Naomi_Mapping = { - { getJoystickXAxis, getJoystickYAxis, getRightTriggerAxis, getLeftTriggerAxis }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 }, - { 0x40, 0x01, 0x02, 0x80, 0x20, 0x10, 0x08, 0x04, 0, 0x80, 0x40, 0, 0 }, -// SERVICE BTN1 BTN0 START UP DOWN LEFT RIGHT BTN2 BTN3 +u32 naomi_button_mapping[] = { + NAOMI_SERVICE_KEY, // DC_BTN_C + NAOMI_BTN1_KEY, // DC_BTN_B + NAOMI_BTN0_KEY, // DC_BTN_A + NAOMI_START_KEY, // DC_BTN_START + NAOMI_UP_KEY, // DC_DPAD_UP + NAOMI_DOWN_KEY, // DC_DPAD_DOWN + NAOMI_LEFT_KEY, // DC_DPAD_LEFT + NAOMI_RIGHT_KEY, // DC_DPAD_RIGHT + NAOMI_TEST_KEY, // DC_BTN_Z + NAOMI_BTN3_KEY, // DC_BTN_Y + NAOMI_BTN2_KEY, // DC_BTN_X + NAOMI_COIN_KEY, // DC_BTN_D + // DC_DPAD2_UP + // DC_DPAD2_DOWN + // DC_DPAD2_LEFT + // DC_DPAD2_RIGHT }; - /* * Sega JVS I/O board */ -bool coin_chute; -static bool old_coin_chute; -static int coin_count; -bool naomi_test_button = false; +static bool old_coin_chute[4]; +static int coin_count[4]; struct maple_naomi_jamma; @@ -2313,63 +2354,56 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou { JVS_STATUS1(); // report byte - LOGJVS("btns "); - JVS_OUT(naomi_test_button ? 0x80 : 0x00); // test, tilt1, tilt2, tilt3, unused, unused, unused, unused - // FIXME in-lst mapping - u8 buttons[8] = { 0 }; - u32 keycode = ~kcode[0]; - for (int i = 0; i < 16; i++) - if ((keycode & (1 << i)) != 0) - { - buttons[Naomi_Mapping.button_mapping_byte[i]] |= Naomi_Mapping.button_mapping_mask[i]; - } - for (int player = 0; player < buffer_in[cmdi + 1]; player++) + u16 buttons[4] = { 0 }; + for (int player = 0; player < buffer_in[cmdi + 1] && first_player + player < ARRAY_SIZE(kcode); player++) { - u8 *cur_btns = &buttons[(first_player + player) * 2]; - LOGJVS("P%d %02x ", player + 1 + first_player, cur_btns[0]); - JVS_OUT(cur_btns[0]); - if (buffer_in[cmdi + 2] == 2) + u32 keycode = ~kcode[first_player + player]; + for (int i = 0; i < 16; i++) { - LOGJVS("%02x ", cur_btns[1]); - JVS_OUT(cur_btns[1]); + if ((keycode & (1 << i)) != 0) + buttons[player] |= naomi_button_mapping[i]; + } + } + + LOGJVS("btns "); + JVS_OUT((buttons[0] & NAOMI_TEST_KEY) ? 0x80 : 0x00); // test, tilt1, tilt2, tilt3, unused, unused, unused, unused + for (int player = 0; player < buffer_in[cmdi + 1]; player++) + { + u16 cur_btns = first_player + player < ARRAY_SIZE(buttons) ? buttons[first_player + player] : 0; + LOGJVS("P%d %02x ", player + 1 + first_player, cur_btns >> 8); + JVS_OUT(cur_btns >> 8); + if (buffer_in[cmdi + 2] == 2) + { + LOGJVS("%02x ", cur_btns & 0xFF); + JVS_OUT(cur_btns); } } -// for (int player = 0; player < jvs_request[channel][cmdi + 1]; player++) -// { -// u32 keycode = ~kcode[player]; -// if (keycode & DC_BTN_C) -// keycode |= 0xFFff; -// -// if (jvs_request[channel][cmdi + 2] == 1) -// JVS_OUT(keycode); -// else -// w16(keycode); -// } cmdi += 3; } break; case 0x21: // Read coins { - if (coin_chute && !old_coin_chute) - coin_count++; - old_coin_chute = coin_chute; JVS_STATUS1(); // report byte LOGJVS("coins "); for (int slot = 0; slot < buffer_in[cmdi + 1]; slot++) { - if (slot == 0) + bool coin_chute = false; + u32 keycode = ~kcode[first_player + slot]; + for (int i = 0; i < 16 && !coin_chute; i++) { - LOGJVS("0:%d ", coin_count); - JVS_OUT((coin_count >> 8) & 0x3F); // status (2 highest bits, 0: normal), coin count MSB - JVS_OUT(coin_count); // coin count LSB - } - else - { - LOGJVS("%d:0 ", slot); - JVS_OUT(0); - JVS_OUT(0); + if (naomi_button_mapping[i] == NAOMI_COIN_KEY && (keycode & (1 << i)) != 0) + coin_chute = true; } + if (coin_chute && !old_coin_chute[first_player + slot]) + coin_count[first_player + slot] += 1; + old_coin_chute[first_player + slot] = coin_chute; + + LOGJVS("%d:%d ", slot + 1 + first_player, coin_count[first_player + slot]); + // status (2 highest bits, 0: normal), coin count MSB + JVS_OUT((coin_count[first_player + slot] >> 8) & 0x3F); + // coin count LSB + JVS_OUT(coin_count[first_player + slot]); } cmdi += 2; } @@ -2393,34 +2427,50 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou } LOGJVS("x,y:%4x,%4x ", x, y); JVS_OUT(x >> 8); // X, MSB - JVS_OUT(x); // X, LSB + JVS_OUT(x); // X, LSB JVS_OUT(y >> 8); // Y, MSB - JVS_OUT(y); // Y, LSB + JVS_OUT(y); // Y, LSB axis = 2; } + int full_axis_count = 0; + int half_axis_count = 0; for (; axis < buffer_in[cmdi + 1]; axis++) { - // FIXME Need to know how many axes per player for proper mapping u16 axis_value; - if (axis + first_player * 4 < 8 && Naomi_Mapping.axis[axis + first_player * 4] != NULL) - axis_value = Naomi_Mapping.axis[axis + first_player * 4](); + if (NaomiGameInputs != NULL + && axis < ARRAY_SIZE(NaomiGameInputs->axes) + && NaomiGameInputs->axes[axis].name != NULL + && NaomiGameInputs->axes[axis].type == Half) + { + if (half_axis_count == 0) + axis_value = rt[first_player] << 8; + else if (half_axis_count == 1) + axis_value = lt[first_player] << 8; + else + axis_value = 0; + half_axis_count++; + } else { - switch (axis) { + switch (full_axis_count) { case 0: - axis_value = (joyx[first_player + axis / 4] + 128) << 8; + axis_value = (joyx[first_player] + 128) << 8; break; case 1: - axis_value = (joyy[first_player + axis / 4] + 128) << 8; - break; - case 2: - axis_value = rt[first_player + axis / 4] << 8; - break; - case 3: - axis_value = lt[first_player + axis / 4] << 8; + axis_value = (joyy[first_player] + 128) << 8; break; + // TODO right analog stick +// case 2: +// axis_value = (joyrx[first_player] + 128) << 8; +// break; +// case 3: +// axis_value = (joyry[first_player] + 128) << 8; +// break; + default: + axis_value = 128; } + full_axis_count++; } LOGJVS("%d:%4x ", axis, axis_value); JVS_OUT(axis_value >> 8); @@ -2493,8 +2543,8 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou break; case 0x30: // substract coin - if (buffer_in[cmdi + 1] == 1) - coin_count -= (buffer_in[cmdi + 2] << 8) + buffer_in[cmdi + 3]; + if (buffer_in[cmdi + 1] > 0 && first_player + buffer_in[cmdi + 1] - 1 < ARRAY_SIZE(coin_count)) + coin_count[first_player + buffer_in[cmdi + 1] - 1] -= (buffer_in[cmdi + 2] << 8) + buffer_in[cmdi + 3]; JVS_STATUS1(); // report byte cmdi += 4; break; diff --git a/core/hw/naomi/naomi.cpp b/core/hw/naomi/naomi.cpp index 3f2a40af8..1b75b1a03 100644 --- a/core/hw/naomi/naomi.cpp +++ b/core/hw/naomi/naomi.cpp @@ -6,6 +6,7 @@ #include "hw/holly/sb.h" #include "hw/sh4/sh4_mem.h" #include "hw/holly/holly_intc.h" +#include "hw/maple/maple_cfg.h" #include "naomi.h" #include "naomi_cart.h" @@ -634,7 +635,6 @@ void Update_naomi() } static u8 aw_maple_devs; -extern bool coin_chute; u32 libExtDevice_ReadMem_A0_006(u32 addr,u32 size) { addr &= 0x7ff; @@ -653,12 +653,13 @@ u32 libExtDevice_ReadMem_A0_006(u32 addr,u32 size) { aw_ram_test_skipped = true; return 0; } - if (coin_chute) { - // FIXME Coin Error if coin_chute is set for too long - return 0xE; + u8 coin_input = 0xF; + for (int slot = 0; slot < 4; slot++) + if (maple_atomiswave_coin_chute(slot)) + coin_input &= ~(1 << slot); + return coin_input; } - return 0xF; case 0x284: // Atomiswave maple devices // ddcc0000 where cc/dd are the types of devices on maple bus 2 and 3: diff --git a/core/hw/naomi/naomi_cart.cpp b/core/hw/naomi/naomi_cart.cpp index 1dee0c64f..e9b18e2c0 100644 --- a/core/hw/naomi/naomi_cart.cpp +++ b/core/hw/naomi/naomi_cart.cpp @@ -32,7 +32,7 @@ fd_t* RomCacheMap = NULL; u32 RomCacheMapCount; char naomi_game_id[33]; -InputDescriptors *naomi_game_inputs; +InputDescriptors *NaomiGameInputs; u8 *naomi_default_eeprom; extern RomChip sys_rom; @@ -246,7 +246,7 @@ static bool naomi_cart_LoadZip(char *filename) break; } CurrentCartridge->SetKey(game->key); - naomi_game_inputs = game->inputs; + NaomiGameInputs = game->inputs; for (int romid = 0; game->blobs[romid].filename != NULL; romid++) { diff --git a/core/hw/naomi/naomi_cart.h b/core/hw/naomi/naomi_cart.h index b5c9745dc..918de1b72 100644 --- a/core/hw/naomi/naomi_cart.h +++ b/core/hw/naomi/naomi_cart.h @@ -110,6 +110,6 @@ struct InputDescriptors AxisDescriptor axes[8]; }; -extern InputDescriptors *naomi_game_inputs; +extern InputDescriptors *NaomiGameInputs; #endif //NAOMI_CART_H diff --git a/core/linux-dist/x11.cpp b/core/linux-dist/x11.cpp index 85c6fd5f1..aa71bdbdf 100644 --- a/core/linux-dist/x11.cpp +++ b/core/linux-dist/x11.cpp @@ -84,8 +84,6 @@ Atom wmDeleteMessage; void* x11_vis; extern bool dump_frame_switch; -extern bool naomi_test_button; -extern bool coin_chute; void dc_exit(void); @@ -275,16 +273,6 @@ void input_x11_handle() x11_fullscreen = !x11_fullscreen; x11_window_set_fullscreen(x11_fullscreen); } -#if DC_PLATFORM == DC_PLATFORM_NAOMI || DC_PLATFORM == DC_PLATFORM_ATOMISWAVE - else if (e.xkey.keycode == KEY_F8) - { - coin_chute = e.type == KeyPress; - } - else if (e.xkey.keycode == KEY_F7) - { - naomi_test_button = e.type == KeyPress; - } -#endif } } break; diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 1731193e9..68db4682c 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -188,8 +188,6 @@ u16 kcode[4] = { 0xffff, 0xffff, 0xffff, 0xffff }; u32 vks[4]; s8 joyx[4],joyy[4]; u8 rt[4],lt[4]; -extern bool coin_chute; -extern bool naomi_test_button; // Mouse extern s32 mo_x_abs; extern s32 mo_y_abs; @@ -220,12 +218,6 @@ void UpdateInputState(u32 port) std::shared_ptr gamepad = XInputGamepadDevice::GetXInputDevice(port); if (gamepad != NULL) gamepad->ReadInput(); - -#if DC_PLATFORM == DC_PLATFORM_NAOMI || DC_PLATFORM == DC_PLATFORM_ATOMISWAVE - // FIXME - coin_chute = GetAsyncKeyState(VK_F8); - naomi_test_button = GetAsyncKeyState(VK_F7); -#endif } // Windows class name to register From 4b7e4f467795ea67e38e2538c86112e92df18b34 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sat, 6 Apr 2019 19:38:00 +0200 Subject: [PATCH 21/73] custom textures: fix race conditions --- core/rend/gles/CustomTexture.cpp | 34 ++++++++++++++++++-------------- core/rend/gles/CustomTexture.h | 2 +- core/rend/gles/gles.cpp | 3 --- core/rend/gles/gles.h | 9 +++++---- core/rend/gles/gltex.cpp | 19 ++++-------------- 5 files changed, 29 insertions(+), 38 deletions(-) diff --git a/core/rend/gles/CustomTexture.cpp b/core/rend/gles/CustomTexture.cpp index 3d8db4561..0a9a20176 100644 --- a/core/rend/gles/CustomTexture.cpp +++ b/core/rend/gles/CustomTexture.cpp @@ -46,23 +46,28 @@ void CustomTexture::LoaderThread() if (texture != NULL) { - // FIXME texture may have been deleted. Need to detect this. texture->ComputeHash(); - int width, height; - u8 *image_data = LoadCustomTexture(texture->texture_hash, width, height); - if (image_data == NULL) + if (texture->custom_image_data != NULL) { - image_data = LoadCustomTexture(texture->old_texture_hash, width, height); + delete [] texture->custom_image_data; + texture->custom_image_data = NULL; } - if (image_data != NULL) + if (!texture->dirty) { - if (texture->custom_image_data != NULL) - delete [] texture->custom_image_data; - texture->custom_width = width; - texture->custom_height = height; - texture->custom_image_data = image_data; + int width, height; + u8 *image_data = LoadCustomTexture(texture->texture_hash, width, height); + if (image_data == NULL) + { + image_data = LoadCustomTexture(texture->old_texture_hash, width, height); + } + if (image_data != NULL) + { + texture->custom_width = width; + texture->custom_height = height; + texture->custom_image_data = image_data; + } } - texture->custom_load_in_progress = false; + texture->custom_load_in_progress--; } } while (texture != NULL); @@ -140,10 +145,9 @@ u8* CustomTexture::LoadCustomTexture(u32 hash, int& width, int& height) void CustomTexture::LoadCustomTextureAsync(TextureCacheData *texture_data) { if (!Init()) - { - texture_data->custom_load_in_progress = false; return; - } + + texture_data->custom_load_in_progress++; work_queue_mutex.Lock(); work_queue.insert(work_queue.begin(), texture_data); work_queue_mutex.Unlock(); diff --git a/core/rend/gles/CustomTexture.h b/core/rend/gles/CustomTexture.h index d0847717b..830855542 100644 --- a/core/rend/gles/CustomTexture.h +++ b/core/rend/gles/CustomTexture.h @@ -53,7 +53,7 @@ private: cThread loader_thread; #endif cResetEvent wakeup_thread; - std::vector work_queue; + std::vector work_queue; cMutex work_queue_mutex; }; diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index b97d9e4e2..b243a6ffc 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -1838,9 +1838,6 @@ bool RenderFrame() glBufferData(GL_ARRAY_BUFFER,pvrrc.modtrig.bytes(),pvrrc.modtrig.head(),GL_STREAM_DRAW); glCheck(); } - int offs_x=ds2s_offs_x+0.5f; - //this needs to be scaled - //not all scaling affects pixel operations, scale to adjust for that scale_x *= scissoring_scale_x; diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index 832ecf31a..c6339b802 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include "rend/rend.h" #if (defined(GLES) && !defined(TARGET_NACL32) && HOST_OS != OS_DARWIN && !defined(USE_SDL)) || defined(_ANDROID) @@ -271,10 +272,10 @@ struct TextureCacheData //a texture can't be both VQ and PAL at the same time u32 texture_hash; // xxhash of texture data, used for custom textures u32 old_texture_hash; // legacy hash - u8* custom_image_data; // loaded custom image data - u32 custom_width; - u32 custom_height; - bool custom_load_in_progress; + u8* volatile custom_image_data; // loaded custom image data + volatile u32 custom_width; + volatile u32 custom_height; + std::atomic_int custom_load_in_progress; void PrintTextureName(); diff --git a/core/rend/gles/gltex.cpp b/core/rend/gles/gltex.cpp index ef6263ddc..5bf3b45eb 100644 --- a/core/rend/gles/gltex.cpp +++ b/core/rend/gles/gltex.cpp @@ -296,10 +296,7 @@ void TextureCacheData::Update() } } if (settings.rend.CustomTextures) - { - custom_load_in_progress = true; custom_texture.LoadCustomTextureAsync(this); - } void *temp_tex_buffer = NULL; u32 upscaled_w = w; @@ -428,7 +425,7 @@ void TextureCacheData::UploadToGPU(GLuint textype, int width, int height, u8 *te void TextureCacheData::CheckCustomTexture() { - if (custom_image_data != NULL) + if (custom_load_in_progress == 0 && custom_image_data != NULL) { UploadToGPU(GL_UNSIGNED_BYTE, custom_width, custom_height, custom_image_data); delete [] custom_image_data; @@ -446,7 +443,7 @@ bool TextureCacheData::NeedsUpdate() { bool TextureCacheData::Delete() { - if (custom_load_in_progress) + if (custom_load_in_progress > 0) return false; if (pData) { @@ -736,11 +733,7 @@ TextureCacheData *getTextureCacheData(TSP tsp, TCW tcw) { } else //create if not existing { - TextureCacheData tfc={0}; - TexCache[key] = tfc; - - tx=TexCache.find(key); - tf=&tx->second; + tf=&TexCache[key]; tf->tsp = tsp; tf->tcw = tcw; @@ -800,11 +793,7 @@ text_info raw_GetTexture(TSP tsp, TCW tcw) } else //create if not existing { - TextureCacheData tfc = { 0 }; - TexCache[key] = tfc; - - tx = TexCache.find(key); - tf = &tx->second; + tf = &TexCache[key]; tf->tsp = tsp; tf->tcw = tcw; From 408d16b2993302b1c5384b4876cf7e14df328d01 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sun, 7 Apr 2019 23:33:24 +0200 Subject: [PATCH 22/73] imgui: clear color buffer before drawing background tex fixes blinking edges on nvidia shield and other glitches --- core/rend/gles/imgui_impl_opengl3.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/rend/gles/imgui_impl_opengl3.cpp b/core/rend/gles/imgui_impl_opengl3.cpp index 853e41563..ddb363c1c 100644 --- a/core/rend/gles/imgui_impl_opengl3.cpp +++ b/core/rend/gles/imgui_impl_opengl3.cpp @@ -510,6 +510,9 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects() void ImGui_ImplOpenGL3_DrawBackground() { + glcache.Disable(GL_SCISSOR_TEST); + glcache.ClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); if (g_BackgroundTexture != 0) { ImGuiIO& io = ImGui::GetIO(); @@ -520,11 +523,6 @@ void ImGui_ImplOpenGL3_DrawBackground() ImGui::GetWindowDrawList()->AddImage((ImTextureID)(uintptr_t)g_BackgroundTexture, ImVec2(0, 0), io.DisplaySize, ImVec2(0, 1), ImVec2(1, 0), 0xffffffff); ImGui::End(); } - else - { - glcache.ClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); - } } ImTextureID ImGui_ImplOpenGL3_CreateVmuTexture(const unsigned int *data) From 47bb509f02802cf6c8a233d249573ba6c118b1a2 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 8 Apr 2019 00:21:06 +0200 Subject: [PATCH 23/73] Add horizontal screen stretching option fix scissor test when scaling/stretching fix infiniloop when starting a game fails --- core/nullDC.cpp | 7 ++++- core/rend/gl4/gldraw.cpp | 12 ++++++--- core/rend/gl4/gles.cpp | 25 ++++++++--------- core/rend/gles/gldraw.cpp | 34 ++++++++++++++--------- core/rend/gles/gles.cpp | 27 ++++++++++--------- core/rend/gles/gles.h | 1 + core/rend/gles/gltex.cpp | 57 ++++++++++++++++++++++++++------------- core/rend/gui.cpp | 4 +++ core/types.h | 3 ++- 9 files changed, 108 insertions(+), 62 deletions(-) diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 89c637803..844e38ba9 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -313,7 +313,9 @@ int dc_start_game(const char *path) #if DC_PLATFORM == DC_PLATFORM_DREAMCAST if (!settings.bios.UseReios) #endif - LoadRomFiles(get_readonly_data_path(DATA_PATH)); + if (!LoadRomFiles(get_readonly_data_path(DATA_PATH))) + return -5; + #if DC_PLATFORM == DC_PLATFORM_DREAMCAST if (path == NULL) { @@ -513,6 +515,7 @@ void InitSettings() settings.rend.CustomTextures = false; settings.rend.DumpTextures = false; settings.rend.ScreenScaling = 100; + settings.rend.ScreenStretching = 100; settings.rend.Fog = true; settings.pvr.ta_skip = 0; @@ -596,6 +599,7 @@ void LoadSettings(bool game_specific) settings.rend.DumpTextures = cfgLoadBool(config_section, "rend.DumpTextures", settings.rend.DumpTextures); settings.rend.ScreenScaling = cfgLoadInt(config_section, "rend.ScreenScaling", settings.rend.ScreenScaling); settings.rend.ScreenScaling = min(max(1, settings.rend.ScreenScaling), 100); + settings.rend.ScreenStretching = cfgLoadInt(config_section, "rend.ScreenStretching", settings.rend.ScreenStretching); settings.rend.Fog = cfgLoadBool(config_section, "rend.Fog", settings.rend.Fog); settings.pvr.ta_skip = cfgLoadInt(config_section, "ta.skip", settings.pvr.ta_skip); @@ -720,6 +724,7 @@ void SaveSettings() cfgSaveBool("config", "rend.CustomTextures", settings.rend.CustomTextures); cfgSaveBool("config", "rend.DumpTextures", settings.rend.DumpTextures); cfgSaveInt("config", "rend.ScreenScaling", settings.rend.ScreenScaling); + cfgSaveInt("config", "rend.ScreenStretching", settings.rend.ScreenStretching); cfgSaveBool("config", "rend.Fog", settings.rend.Fog); cfgSaveInt("config", "ta.skip", settings.pvr.ta_skip); cfgSaveInt("config", "pvr.rend", settings.pvr.rend); diff --git a/core/rend/gl4/gldraw.cpp b/core/rend/gl4/gldraw.cpp index 447a97461..75ad7eda9 100644 --- a/core/rend/gl4/gldraw.cpp +++ b/core/rend/gl4/gldraw.cpp @@ -697,11 +697,15 @@ void gl4DrawFramebuffer(float w, float h) bool gl4_render_output_framebuffer() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, screen_width, screen_height); - if (gl.ofbo.tex == 0) + glcache.Disable(GL_SCISSOR_TEST); + if (gl.ofbo.fbo == 0) return false; - - gl4_draw_quad_texture(gl.ofbo.tex, true); + glBindFramebuffer(GL_READ_FRAMEBUFFER, gl.ofbo.fbo); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBlitFramebuffer(0, 0, gl.ofbo.width, gl.ofbo.height, + 0, 0, screen_width, screen_height, + GL_COLOR_BUFFER_BIT, GL_LINEAR); + glBindFramebuffer(GL_FRAMEBUFFER, 0); return true; } diff --git a/core/rend/gl4/gles.cpp b/core/rend/gl4/gles.cpp index ecda63dec..93700f20b 100644 --- a/core/rend/gl4/gles.cpp +++ b/core/rend/gl4/gles.cpp @@ -662,14 +662,15 @@ static bool RenderFrame() Handle Dc to screen scaling */ float screen_scaling = is_rtt ? 1.f : settings.rend.ScreenScaling / 100.f; + float screen_stretching = settings.rend.ScreenStretching / 100.f; + float dc2s_scale_h = is_rtt ? (screen_width / dc_width) : (screen_height / 480.0); - dc2s_scale_h *= screen_scaling; - float ds2s_offs_x = is_rtt ? 0 : (((screen_width * screen_scaling) - dc2s_scale_h * 640.0) / 2); + float ds2s_offs_x = is_rtt ? 0 : ((screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2); //-1 -> too much to left - gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width * screen_scaling / dc2s_scale_h * scale_x); + gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; gl4ShaderUniforms.scale_coefs[1] = (is_rtt ? 2 : -2) / dc_height; // FIXME CT2 needs 480 here instead of dc_height=512 - gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / (screen_width * screen_scaling); + gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width; gl4ShaderUniforms.scale_coefs[3] = (is_rtt ? 1 : -1); gl4ShaderUniforms.extra_depth_scale = settings.rend.ExtraDepthScale; @@ -763,7 +764,7 @@ static bool RenderFrame() { if (settings.rend.ScreenScaling != 100 || gl.swap_buffer_not_preserved) { - output_fbo = init_output_framebuffer(screen_width * screen_scaling, screen_height * screen_scaling); + output_fbo = init_output_framebuffer(screen_width * screen_scaling + 0.5f, screen_height * screen_scaling + 0.5f); } else { @@ -826,21 +827,21 @@ static bool RenderFrame() if (!is_rtt) { // Add x offset for aspect ratio > 4/3 - min_x = min_x * dc2s_scale_h + ds2s_offs_x; + min_x = min_x * dc2s_scale_h * screen_stretching + ds2s_offs_x * screen_scaling; // Invert y coordinates when rendering to screen - min_y = screen_height * screen_scaling - (min_y + height) * dc2s_scale_h; - width *= dc2s_scale_h; - height *= dc2s_scale_h; + min_y = (screen_height - (min_y + height) * dc2s_scale_h) * screen_scaling; + width *= dc2s_scale_h * screen_scaling * screen_stretching; + height *= dc2s_scale_h * screen_scaling; if (ds2s_offs_x > 0) { - float rounded_offs_x = ds2s_offs_x + 0.5f; + float scaled_offs_x = ds2s_offs_x * screen_scaling; glcache.ClearColor(0.f, 0.f, 0.f, 0.f); glcache.Enable(GL_SCISSOR_TEST); - glScissor(0, 0, rounded_offs_x, screen_height); + glScissor(0, 0, scaled_offs_x + 0.5f, screen_height * screen_scaling + 0.5f); glClear(GL_COLOR_BUFFER_BIT); - glScissor(screen_width - rounded_offs_x, 0, rounded_offs_x, screen_height); + glScissor(screen_width * screen_scaling - scaled_offs_x + 0.5f, 0, scaled_offs_x + 1.f, screen_height * screen_scaling + 0.5f); glClear(GL_COLOR_BUFFER_BIT); } } diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index d337848cb..618a3e33f 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -1141,17 +1141,27 @@ void DrawFramebuffer(float w, float h) bool render_output_framebuffer() { -#if HOST_OS != OS_DARWIN - //Fix this in a proper way - glBindFramebuffer(GL_FRAMEBUFFER, 0); -#endif - glViewport(0, 0, screen_width, screen_height); - if (gl.ofbo.tex == 0) - return false; - - float scl = 480.f / screen_height; - float tx = (screen_width * scl - 640.f) / 2; - DrawQuad(gl.ofbo.tex, -tx, 0, 640.f + tx * 2, 480.f, 0, 1, 1, 0); - + glcache.Disable(GL_SCISSOR_TEST); + if (gl.gl_major < 3) + { + glViewport(0, 0, screen_width, screen_height); + if (gl.ofbo.tex == 0) + return false; + glBindFramebuffer(GL_FRAMEBUFFER, 0); + float scl = 480.f / screen_height; + float tx = (screen_width * scl - 640.f) / 2; + DrawQuad(gl.ofbo.tex, -tx, 0, 640.f + tx * 2, 480.f, 0, 1, 1, 0); + } + else + { + if (gl.ofbo.fbo == 0) + return false; + glBindFramebuffer(GL_READ_FRAMEBUFFER, gl.ofbo.fbo); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBlitFramebuffer(0, 0, gl.ofbo.width, gl.ofbo.height, + 0, 0, screen_width, screen_height, + GL_COLOR_BUFFER_BIT, GL_LINEAR); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + } return true; } diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index b243a6ffc..fad89106d 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -1678,15 +1678,16 @@ bool RenderFrame() /* Handle Dc to screen scaling */ - float screen_scaling = is_rtt ? 1.f : settings.rend.ScreenScaling / 100.f; + float screen_stretching = settings.rend.ScreenStretching / 100.f; + float screen_scaling = settings.rend.ScreenScaling / 100.f; + float dc2s_scale_h = is_rtt ? (screen_width / dc_width) : (screen_height / 480.0); - dc2s_scale_h *= screen_scaling; - float ds2s_offs_x = is_rtt ? 0 : (((screen_width * screen_scaling) - dc2s_scale_h * 640.0) / 2); + float ds2s_offs_x = is_rtt ? 0 : ((screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2); //-1 -> too much to left - ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width * screen_scaling / dc2s_scale_h * scale_x); + ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; ShaderUniforms.scale_coefs[1]= (is_rtt ? 2 : -2) / dc_height; // FIXME CT2 needs 480 here instead of dc_height=512 - ShaderUniforms.scale_coefs[2]= 1 - 2 * ds2s_offs_x / (screen_width * screen_scaling); + ShaderUniforms.scale_coefs[2]= 1 - 2 * ds2s_offs_x / screen_width; ShaderUniforms.scale_coefs[3]= (is_rtt ? 1 : -1); @@ -1791,7 +1792,7 @@ bool RenderFrame() { if (settings.rend.ScreenScaling != 100 || gl.swap_buffer_not_preserved) { - init_output_framebuffer(screen_width * screen_scaling, screen_height * screen_scaling); + init_output_framebuffer(screen_width * screen_scaling + 0.5f, screen_height * screen_scaling + 0.5f); } else { @@ -1857,21 +1858,21 @@ bool RenderFrame() if (!is_rtt) { // Add x offset for aspect ratio > 4/3 - min_x = min_x * dc2s_scale_h + ds2s_offs_x; + min_x = min_x * dc2s_scale_h * screen_stretching + ds2s_offs_x * screen_scaling; // Invert y coordinates when rendering to screen - min_y = screen_height * screen_scaling - (min_y + height) * dc2s_scale_h; - width *= dc2s_scale_h; - height *= dc2s_scale_h; + min_y = (screen_height - (min_y + height) * dc2s_scale_h) * screen_scaling; + width *= dc2s_scale_h * screen_scaling * screen_stretching; + height *= dc2s_scale_h * screen_scaling; if (ds2s_offs_x > 0) { - float rounded_offs_x = ds2s_offs_x + 0.5f; + float scaled_offs_x = ds2s_offs_x * screen_scaling; glcache.ClearColor(0.f, 0.f, 0.f, 0.f); glcache.Enable(GL_SCISSOR_TEST); - glScissor(0, 0, rounded_offs_x, screen_height); + glScissor(0, 0, scaled_offs_x + 0.5f, screen_height * screen_scaling + 0.5f); glClear(GL_COLOR_BUFFER_BIT); - glScissor(screen_width - rounded_offs_x, 0, rounded_offs_x, screen_height); + glScissor(screen_width * screen_scaling - scaled_offs_x + 0.5f, 0, scaled_offs_x + 1.f, screen_height * screen_scaling + 0.5f); glClear(GL_COLOR_BUFFER_BIT); } } diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index c6339b802..7e0cec3cb 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -120,6 +120,7 @@ struct gl_ctx struct { GLuint depthb; + GLuint colorb; GLuint tex; GLuint fbo; int width; diff --git a/core/rend/gles/gltex.cpp b/core/rend/gles/gltex.cpp index 5bf3b45eb..1a3802fb7 100644 --- a/core/rend/gles/gltex.cpp +++ b/core/rend/gles/gltex.cpp @@ -996,13 +996,7 @@ GLuint init_output_framebuffer(int width, int height) { if (width != gl.ofbo.width || height != gl.ofbo.height) { - if (gl.ofbo.fbo != 0) - { - glDeleteFramebuffers(1, &gl.ofbo.fbo); - gl.ofbo.fbo = 0; - glDeleteRenderbuffers(1, &gl.ofbo.depthb); - glcache.DeleteTextures(1, &gl.ofbo.tex); - } + free_output_framebuffer(); gl.ofbo.width = width; gl.ofbo.height = height; } @@ -1026,15 +1020,25 @@ GLuint init_output_framebuffer(int width, int height) else glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); - // Create a texture for rendering to - gl.ofbo.tex = glcache.GenTexture(); - glcache.BindTexture(GL_TEXTURE_2D, gl.ofbo.tex); + if (gl.gl_major < 3) + { + // Create a texture for rendering to + gl.ofbo.tex = glcache.GenTexture(); + glcache.BindTexture(GL_TEXTURE_2D, gl.ofbo.tex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + else + { + // Use a renderbuffer and glBlitFramebuffer + glGenRenderbuffers(1, &gl.ofbo.colorb); + glBindRenderbuffer(GL_RENDERBUFFER, gl.ofbo.colorb); + glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, width, height); + } // Create the framebuffer glGenFramebuffers(1, &gl.ofbo.fbo); @@ -1046,13 +1050,20 @@ GLuint init_output_framebuffer(int width, int height) if (!gl.is_gles || gl.GL_OES_packed_depth_stencil_supported) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gl.ofbo.depthb); - // Attach the texture to the FBO - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl.ofbo.tex, 0); + // Attach the texture/renderbuffer to the FBO + if (gl.gl_major < 3) + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl.ofbo.tex, 0); + else + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, gl.ofbo.colorb); // Check that our FBO creation was successful GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); verify(uStatus == GL_FRAMEBUFFER_COMPLETE); + + glcache.Disable(GL_SCISSOR_TEST); + glcache.ClearColor(0.f, 0.f, 0.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT); } else glBindFramebuffer(GL_FRAMEBUFFER, gl.ofbo.fbo); @@ -1071,7 +1082,15 @@ void free_output_framebuffer() gl.ofbo.fbo = 0; glDeleteRenderbuffers(1, &gl.ofbo.depthb); gl.ofbo.depthb = 0; - glcache.DeleteTextures(1, &gl.ofbo.tex); - gl.ofbo.tex = 0; + if (gl.ofbo.tex != 0) + { + glcache.DeleteTextures(1, &gl.ofbo.tex); + gl.ofbo.tex = 0; + } + if (gl.ofbo.colorb != 0) + { + glDeleteRenderbuffers(1, &gl.ofbo.colorb); + gl.ofbo.colorb = 0; + } } } diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index cfc134cbc..6c096d755 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -952,6 +952,9 @@ static void gui_display_settings() ImGui::SliderInt("Scaling", (int *)&settings.rend.ScreenScaling, 1, 100); ImGui::SameLine(); ShowHelpMarker("Downscaling factor relative to native screen resolution. Higher is better"); + ImGui::SliderInt("Horizontal Stretching", (int *)&settings.rend.ScreenStretching, 100, 150); + ImGui::SameLine(); + ShowHelpMarker("Stretch the screen horizontally"); ImGui::SliderInt("Frame Skipping", (int *)&settings.pvr.ta_skip, 0, 6); ImGui::SameLine(); ShowHelpMarker("Number of frames to skip between two actually rendered frames"); @@ -1251,6 +1254,7 @@ static void gui_start_game(const std::string& path) { gui_state = Main; game_started = false; + cfgSetVirtual("config", "image", ""); switch (rc) { case -3: error_msg = "Audio/video initialization failed"; diff --git a/core/types.h b/core/types.h index a9a835ac1..bfd779ef8 100644 --- a/core/types.h +++ b/core/types.h @@ -632,7 +632,8 @@ struct settings_t f32 ExtraDepthScale; bool CustomTextures; bool DumpTextures; - int ScreenScaling; // in percent. 50 means half the native resolution + int ScreenScaling; // in percent. 50 means half the native resolution + int ScreenStretching; // in percent. 150 means stretch from 4/3 to 6/3 bool Fog; } rend; From d78fc620551dbaa17897e641d993e20bccd1c83b Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 8 Apr 2019 10:11:28 +0200 Subject: [PATCH 24/73] android: fix Send Logs crash --- .../src/main/java/com/reicast/emulator/BaseGLActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/BaseGLActivity.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/BaseGLActivity.java index a0b28e302..94fc19410 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/BaseGLActivity.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/BaseGLActivity.java @@ -298,7 +298,7 @@ public abstract class BaseGLActivity extends Activity implements ActivityCompat. } // Called from native code - private void generateErrorLog() { + protected void generateErrorLog() { try { new GenerateLogs(this).execute(getFilesDir().getAbsolutePath()); } catch (RuntimeException e) { From f5a60ee5f18c18508db3e29e99bbcd650d3978e0 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 8 Apr 2019 15:54:37 +0200 Subject: [PATCH 25/73] New option to display VMUs in game --- core/nullDC.cpp | 3 +++ core/rend/gui.cpp | 55 +++++++++++++++++++++++++++++++++-------------- core/types.h | 1 + 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 844e38ba9..87155fefc 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -517,6 +517,7 @@ void InitSettings() settings.rend.ScreenScaling = 100; settings.rend.ScreenStretching = 100; settings.rend.Fog = true; + settings.rend.FloatVMUs = false; settings.pvr.ta_skip = 0; settings.pvr.rend = 0; @@ -601,6 +602,7 @@ void LoadSettings(bool game_specific) settings.rend.ScreenScaling = min(max(1, settings.rend.ScreenScaling), 100); settings.rend.ScreenStretching = cfgLoadInt(config_section, "rend.ScreenStretching", settings.rend.ScreenStretching); settings.rend.Fog = cfgLoadBool(config_section, "rend.Fog", settings.rend.Fog); + settings.rend.FloatVMUs = cfgLoadBool(config_section, "rend.FloatVMUs", settings.rend.FloatVMUs); settings.pvr.ta_skip = cfgLoadInt(config_section, "ta.skip", settings.pvr.ta_skip); settings.pvr.rend = cfgLoadInt(config_section, "pvr.rend", settings.pvr.rend); @@ -726,6 +728,7 @@ void SaveSettings() cfgSaveInt("config", "rend.ScreenScaling", settings.rend.ScreenScaling); cfgSaveInt("config", "rend.ScreenStretching", settings.rend.ScreenStretching); cfgSaveBool("config", "rend.Fog", settings.rend.Fog); + cfgSaveBool("config", "rend.FloatVMUs", settings.rend.FloatVMUs); cfgSaveInt("config", "ta.skip", settings.pvr.ta_skip); cfgSaveInt("config", "pvr.rend", settings.pvr.rend); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 6c096d755..7a0fb107d 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -294,7 +294,9 @@ static void gui_display_commands() if (!settings_opening) ImGui_ImplOpenGL3_DrawBackground(); - display_vmus(); + if (!settings.rend.FloatVMUs) + // If floating VMUs, they are already visible on the background + display_vmus(); ImGui::SetNextWindowPos(ImVec2(screen_width / 2.f, screen_height / 2.f), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowSize(ImVec2(330 * scaling, 0)); @@ -617,6 +619,8 @@ void directory_selected_callback(bool cancelled, std::string selection) static void gui_display_settings() { + static bool maple_devices_changed; + ImGui_Impl_NewFrame(); ImGui::NewFrame(); @@ -639,10 +643,14 @@ static void gui_display_settings() gui_state = Commands; else gui_state = Main; + if (maple_devices_changed) + { + maple_devices_changed = false; #if DC_PLATFORM == DC_PLATFORM_DREAMCAST - maple_ReconnectDevices(); - reset_vmus(); + maple_ReconnectDevices(); + reset_vmus(); #endif + } SaveSettings(); } if (game_started) @@ -813,7 +821,10 @@ static void gui_display_settings() { bool is_selected = settings.input.maple_devices[bus] == maple_device_type_from_index(i); if (ImGui::Selectable(maple_device_types[i], &is_selected)) + { settings.input.maple_devices[bus] = maple_device_type_from_index(i); + maple_devices_changed = true; + } if (is_selected) ImGui::SetItemDefaultFocus(); } @@ -831,7 +842,10 @@ static void gui_display_settings() { bool is_selected = settings.input.maple_expansion_devices[bus][port] == maple_expansion_device_type_from_index(i); if (ImGui::Selectable(maple_expansion_device_types[i], &is_selected)) + { settings.input.maple_expansion_devices[bus][port] = maple_expansion_device_type_from_index(i); + maple_devices_changed = true; + } if (is_selected) ImGui::SetItemDefaultFocus(); } @@ -949,6 +963,9 @@ static void gui_display_settings() ImGui::Checkbox("Show FPS Counter", &settings.rend.ShowFPS); ImGui::SameLine(); ShowHelpMarker("Show on-screen frame/sec counter"); + ImGui::Checkbox("Show VMU in game", &settings.rend.FloatVMUs); + ImGui::SameLine(); + ShowHelpMarker("Show the VMU LCD screens while in game"); ImGui::SliderInt("Scaling", (int *)&settings.rend.ScreenScaling, 1, 100); ImGui::SameLine(); ShowHelpMarker("Downscaling factor relative to native screen resolution. Higher is better"); @@ -1459,26 +1476,32 @@ void gui_display_osd() if (osd_message.empty()) { message = getFPSNotification(); - if (message.empty()) - return; } else message = osd_message; - ImGui_Impl_NewFrame(); - ImGui::NewFrame(); + if (!message.empty() || settings.rend.FloatVMUs) + { + ImGui_Impl_NewFrame(); + ImGui::NewFrame(); - ImGui::SetNextWindowBgAlpha(0); - ImGui::SetNextWindowPos(ImVec2(0, screen_height), ImGuiCond_Always, ImVec2(0.f, 1.f)); // Lower left corner + if (!message.empty()) + { + ImGui::SetNextWindowBgAlpha(0); + ImGui::SetNextWindowPos(ImVec2(0, screen_height), ImGuiCond_Always, ImVec2(0.f, 1.f)); // Lower left corner - ImGui::Begin("##osd", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoNav - | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoBackground); - ImGui::SetWindowFontScale(1.5); - ImGui::TextColored(ImVec4(1, 1, 0, 0.7), "%s", message.c_str()); - ImGui::End(); + ImGui::Begin("##osd", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoNav + | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoBackground); + ImGui::SetWindowFontScale(1.5); + ImGui::TextColored(ImVec4(1, 1, 0, 0.7), "%s", message.c_str()); + ImGui::End(); + } + if (settings.rend.FloatVMUs) + display_vmus(); - ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + } } void gui_open_onboarding() diff --git a/core/types.h b/core/types.h index bfd779ef8..2479fef25 100644 --- a/core/types.h +++ b/core/types.h @@ -635,6 +635,7 @@ struct settings_t int ScreenScaling; // in percent. 50 means half the native resolution int ScreenStretching; // in percent. 150 means stretch from 4/3 to 6/3 bool Fog; + bool FloatVMUs; } rend; struct From cf7434a9e6609c15534335baa3461eaa7e87a0fd Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 8 Apr 2019 17:09:10 +0200 Subject: [PATCH 26/73] atomiswave: fix coin input. Subclass sega controller instead of #def --- core/hw/maple/maple_cfg.cpp | 2 +- core/hw/maple/maple_devs.cpp | 118 ++++++++++++++++++++++------------- 2 files changed, 77 insertions(+), 43 deletions(-) diff --git a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp index f14562411..fd6c18d18 100644 --- a/core/hw/maple/maple_cfg.cpp +++ b/core/hw/maple/maple_cfg.cpp @@ -115,7 +115,7 @@ bool maple_atomiswave_coin_chute(int slot) { for (int i = 0; i < 16; i++) { - if (awave_button_mapping[i] == AWAVE_COIN_KEY && (kcode[slot] & (1 << i)) == 0) + if ((kcode[slot] & (1 << i)) == 0 && awave_button_mapping[i] == AWAVE_COIN_KEY) return true; } return false; diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index a26a3f01a..8ed632777 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -199,6 +199,35 @@ struct maple_base: maple_device */ struct maple_sega_controller: maple_base { + virtual u32 get_capabilities() { + // byte 0: 0 0 0 0 0 0 0 0 + // byte 1: 0 0 a5 a4 a3 a2 a1 a0 + // byte 2: R2 L2 D2 U2 D X Y Z + // byte 3: R L D U St A B C + + return 0xfe060f00; // 4 analog axes (0-3) X Y A B Start U D L R + } + + virtual u32 process_kcode(u32 kcode) { + return kcode; + } + + virtual u32 get_analog_axis(int index, const PlainJoystickState &pjs) { + switch (index) + { + case 0: + return pjs.trigger[PJTI_R]; // Right trigger + case 1: + return pjs.trigger[PJTI_L]; // Left trigger + case 2: + return pjs.joy[PJAI_X1]; // Stick X + case 3: + return pjs.joy[PJAI_Y1]; // Stick Y + default: + return 0x80; // unused + } + } + virtual MapleDeviceType get_device_type() { return MDT_SegaController; @@ -216,14 +245,9 @@ struct maple_sega_controller: maple_base //struct data //3*4 -#if DC_PLATFORM != DC_PLATFORM_ATOMISWAVE - w32(0xfe060f00); -#else - // More buttons, more digital axes - w32(0xff663f00); -#endif - w32( 0); - w32( 0); + w32(get_capabilities()); + w32(0); + w32(0); //1 area code w8(0xFF); @@ -254,54 +278,28 @@ struct maple_sega_controller: maple_base //4 w32(MFID_0_Input); -#if DC_PLATFORM != DC_PLATFORM_ATOMISWAVE //state data //2 key code - w16(pjs.kcode); + w16(process_kcode(pjs.kcode)); //triggers //1 R - w8(pjs.trigger[PJTI_R]); + w8(get_analog_axis(0, pjs)); //1 L - w8(pjs.trigger[PJTI_L]); + w8(get_analog_axis(1, pjs)); //joyx //1 - w8(pjs.joy[PJAI_X1]); + w8(get_analog_axis(2, pjs)); //joyy //1 - w8(pjs.joy[PJAI_Y1]); + w8(get_analog_axis(3, pjs)); //not used //1 - w8(0x80); + w8(get_analog_axis(4, pjs)); //1 - w8(0x80); -#else - //state data - //2 key code - w16(pjs.kcode | AWAVE_TRIGGER_KEY); - - //not used - //1 - w8(0); - //1 - w8(0); - - //joyx - //1 - w8(pjs.joy[PJAI_X1]); - //joyy - //1 - w8(pjs.joy[PJAI_Y1]); - - //joyrx - //1 - w8(pjs.joy[PJAI_X2]); - //joyry - //1 - w8(pjs.joy[PJAI_Y2]); -#endif + w8(get_analog_axis(5, pjs)); } return MDRS_DataTransfer; @@ -313,6 +311,38 @@ struct maple_sega_controller: maple_base } }; +struct maple_atomiswave_controller: maple_sega_controller +{ + virtual u32 get_capabilities() { + // byte 0: 0 0 0 0 0 0 0 0 + // byte 1: 0 0 a5 a4 a3 a2 a1 a0 + // byte 2: R2 L2 D2 U2 D X Y Z + // byte 3: R L D U St A B C + + return 0xff663f00; // 6 analog axes, X Y L2/D2(?) A B C Start U D L R + } + + virtual u32 process_kcode(u32 kcode) { + return kcode | AWAVE_TRIGGER_KEY; + } + + virtual u32 get_analog_axis(int index, const PlainJoystickState &pjs) { + switch (index) + { + case 2: + return pjs.joy[PJAI_X1]; + case 3: + return pjs.joy[PJAI_Y1]; + case 4: + return pjs.joy[PJAI_X2]; + case 5: + return pjs.joy[PJAI_Y2]; + default: + return 0x80; + } + } +}; + /* Sega Dreamcast Visual Memory Unit This is pretty much done (?) @@ -2592,7 +2622,11 @@ maple_device* maple_Create(MapleDeviceType type) switch(type) { case MDT_SegaController: - rv=new maple_sega_controller(); +#if DC_PLATFORM != DC_PLATFORM_ATOMISWAVE + rv = new maple_sega_controller(); +#else + rv = new maple_atomiswave_controller(); +#endif break; case MDT_Microphone: From b87a1cc31a3f7918e204ab3ac8666f54dc1f6dac Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 8 Apr 2019 19:14:55 +0200 Subject: [PATCH 27/73] atomiswave: setup maple controls depending on game more lightgun fixes but still not working --- core/hw/maple/maple_cfg.cpp | 29 ++++++++++++++++++++--------- core/hw/maple/maple_devs.cpp | 31 +++++++++++++++++++------------ core/nullDC.cpp | 12 ++++++++---- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp index fd6c18d18..4f8c9d2d6 100644 --- a/core/hw/maple/maple_cfg.cpp +++ b/core/hw/maple/maple_cfg.cpp @@ -149,16 +149,27 @@ void mcfg_CreateAtomisWaveControllers() // Game needs analog axes mcfg_Create(MDT_SegaController, 2, 5, 0); mcfg_Create(MDT_SegaController, 3, 5, 1); + // Faster Than Speed needs 1 std controller on port 0 (digital inputs) and one on port 2 (analog axes) + // Maximum Speed same + } + else if (settings.input.JammaSetup == 1) + { + // 4 players + mcfg_Create(MDT_SegaController, 2, 5); + mcfg_Create(MDT_SegaController, 3, 5); + } + else if (settings.input.JammaSetup == 5) + { + // Clay Challenge needs 2 std controllers on port 0 & 1 (digital in) and light guns on port 2 & 3 + // Sports Shooting same + mcfg_Create(MDT_LightGun, 2, 5, 0); + mcfg_Create(MDT_LightGun, 3, 5, 1); + } + else if (settings.input.JammaSetup == 3) + { + // Sega Bass Fishing Challenge needs a mouse (track-ball) on port 2 + mcfg_Create(MDT_Mouse, 2, 5, 0); } -// mcfg_Create(MDT_LightGun, 2, 5, 0); -// mcfg_Create(MDT_LightGun, 3, 5, 1); -// mcfg_Create(MDT_Mouse, 2, 5, 0); - // Guilty Gear Isuka (4P) needs 4 std controllers - // Faster Than Speed needs 1 std controller on port 0 (digital inputs) and one on port 2 (analog axes) - // Maximum Speed same - // Clay Challenge needs 2 std controllers on port 0 & 1 (digital in) and light guns on port 2 & 3 - // Sports Shooting same - // Sega Bass Fishing Challenge needs a mouse (track-ball) on port 3 } void mcfg_CreateDevices() diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index 8ed632777..bb65dde69 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -313,7 +313,7 @@ struct maple_sega_controller: maple_base struct maple_atomiswave_controller: maple_sega_controller { - virtual u32 get_capabilities() { + virtual u32 get_capabilities() override { // byte 0: 0 0 0 0 0 0 0 0 // byte 1: 0 0 a5 a4 a3 a2 a1 a0 // byte 2: R2 L2 D2 U2 D X Y Z @@ -322,11 +322,11 @@ struct maple_atomiswave_controller: maple_sega_controller return 0xff663f00; // 6 analog axes, X Y L2/D2(?) A B C Start U D L R } - virtual u32 process_kcode(u32 kcode) { + virtual u32 process_kcode(u32 kcode) override { return kcode | AWAVE_TRIGGER_KEY; } - virtual u32 get_analog_axis(int index, const PlainJoystickState &pjs) { + virtual u32 get_analog_axis(int index, const PlainJoystickState &pjs) override { switch (index) { case 2: @@ -1329,6 +1329,10 @@ struct maple_mouse : maple_base struct maple_lightgun : maple_base { + virtual u32 process_kcode(u32 kcode) { + return kcode | 0xFF01; + } + virtual MapleDeviceType get_device_type() { return MDT_LightGun; @@ -1377,21 +1381,13 @@ struct maple_lightgun : maple_base PlainJoystickState pjs; config->GetInput(&pjs); - // Also use the mouse buttons - if (!(mo_buttons & 4)) // Left button - pjs.kcode &= ~4; // A - if (!(mo_buttons & 2)) // Right button - pjs.kcode &= ~2; // B - if (!(mo_buttons & 8)) // Wheel button - pjs.kcode &= ~8; // Start - //caps //4 w32(MFID_0_Input); //state data //2 key code - w16(pjs.kcode | 0xFF01); + w16(process_kcode(pjs.kcode)); //not used //2 @@ -1417,6 +1413,13 @@ struct maple_lightgun : maple_base } }; +struct atomiswave_lightgun : maple_lightgun +{ + virtual u32 process_kcode(u32 kcode) override { + return (kcode & AWAVE_TRIGGER_KEY) == 0 ? ~AWAVE_BTN0_KEY : ~0; + } +}; + extern u16 kcode[4]; extern s8 joyx[4],joyy[4]; extern u8 rt[4], lt[4]; @@ -2650,7 +2653,11 @@ maple_device* maple_Create(MapleDeviceType type) break; case MDT_LightGun: +#if DC_PLATFORM != DC_PLATFORM_ATOMISWAVE rv = new maple_lightgun(); +#else + rv = new atomiswave_lightgun(); +#endif break; case MDT_NaomiJamma: diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 87155fefc..dbbfe5325 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -213,12 +213,14 @@ void LoadSpecialSettings() printf("Enabling JVS rotary encoders for game %s\n", naomi_game_id); settings.input.JammaSetup = 2; } - else if (!strcmp("POWER STONE 2 JAPAN", naomi_game_id)) + else if (!strcmp("POWER STONE 2 JAPAN", naomi_game_id) // Naomi + || !strcmp("GUILTY GEAR isuka", naomi_game_id)) // AW { printf("Enabling 4-player setup for game %s\n", naomi_game_id); settings.input.JammaSetup = 1; } - else if (!strcmp("SEGA MARINE FISHING JAPAN", naomi_game_id)) + else if (!strcmp("SEGA MARINE FISHING JAPAN", naomi_game_id) + || !strcmp(naomi_game_id, "BASS FISHING SIMULATOR VER.A")) // AW { printf("Enabling specific JVS setup for game %s\n", naomi_game_id); settings.input.JammaSetup = 3; @@ -228,9 +230,11 @@ void LoadSpecialSettings() printf("Enabling specific JVS setup for game %s\n", naomi_game_id); settings.input.JammaSetup = 4; } - else if (!strcmp("NINJA ASSAULT", naomi_game_id)) + else if (!strcmp("NINJA ASSAULT", naomi_game_id) + || !strcmp(naomi_game_id, "Sports Shooting USA") // AW + || !strcmp(naomi_game_id, "SEGA CLAY CHALLENGE")) // AW { - printf("Enabling specific JVS setup for game %s\n", naomi_game_id); + printf("Enabling lightgun setup for game %s\n", naomi_game_id); settings.input.JammaSetup = 5; } else if (!strcmp(" BIOHAZARD GUN SURVIVOR2", naomi_game_id)) From 0a6f503efcb712d9d53b7f6530f1d8c67802d8be Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 8 Apr 2019 21:51:59 +0200 Subject: [PATCH 28/73] Don't use screen stretching parameter for RTT --- core/rend/gl4/gles.cpp | 28 ++++++++++++++++++++-------- core/rend/gles/gles.cpp | 27 +++++++++++++++++++-------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/core/rend/gl4/gles.cpp b/core/rend/gl4/gles.cpp index 93700f20b..73330cc66 100644 --- a/core/rend/gl4/gles.cpp +++ b/core/rend/gl4/gles.cpp @@ -661,17 +661,29 @@ static bool RenderFrame() /* Handle Dc to screen scaling */ - float screen_scaling = is_rtt ? 1.f : settings.rend.ScreenScaling / 100.f; + float screen_scaling = settings.rend.ScreenScaling / 100.f; float screen_stretching = settings.rend.ScreenStretching / 100.f; - float dc2s_scale_h = is_rtt ? (screen_width / dc_width) : (screen_height / 480.0); - float ds2s_offs_x = is_rtt ? 0 : ((screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2); + float dc2s_scale_h; + float ds2s_offs_x; - //-1 -> too much to left - gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; - gl4ShaderUniforms.scale_coefs[1] = (is_rtt ? 2 : -2) / dc_height; // FIXME CT2 needs 480 here instead of dc_height=512 - gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width; - gl4ShaderUniforms.scale_coefs[3] = (is_rtt ? 1 : -1); + if (is_rtt) + { + gl4ShaderUniforms.scale_coefs[0] = 2.0f / dc_width; + gl4ShaderUniforms.scale_coefs[1] = 2.0f / dc_height; // FIXME CT2 needs 480 here instead of dc_height=512 + gl4ShaderUniforms.scale_coefs[2] = 1; + gl4ShaderUniforms.scale_coefs[3] = 1; + } + else + { + dc2s_scale_h = screen_height / 480.0; + ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2; + //-1 -> too much to left + gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; + gl4ShaderUniforms.scale_coefs[1] = -2.0f / dc_height; + gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width; + gl4ShaderUniforms.scale_coefs[3] = -1; + } gl4ShaderUniforms.extra_depth_scale = settings.rend.ExtraDepthScale; diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index fad89106d..b16274d99 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -1681,15 +1681,26 @@ bool RenderFrame() float screen_stretching = settings.rend.ScreenStretching / 100.f; float screen_scaling = settings.rend.ScreenScaling / 100.f; - float dc2s_scale_h = is_rtt ? (screen_width / dc_width) : (screen_height / 480.0); - float ds2s_offs_x = is_rtt ? 0 : ((screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2); - - //-1 -> too much to left - ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; - ShaderUniforms.scale_coefs[1]= (is_rtt ? 2 : -2) / dc_height; // FIXME CT2 needs 480 here instead of dc_height=512 - ShaderUniforms.scale_coefs[2]= 1 - 2 * ds2s_offs_x / screen_width; - ShaderUniforms.scale_coefs[3]= (is_rtt ? 1 : -1); + float dc2s_scale_h; + float ds2s_offs_x; + if (is_rtt) + { + ShaderUniforms.scale_coefs[0] = 2.0f / dc_width; + ShaderUniforms.scale_coefs[1] = 2.0f / dc_height; // FIXME CT2 needs 480 here instead of dc_height=512 + ShaderUniforms.scale_coefs[2] = 1; + ShaderUniforms.scale_coefs[3] = 1; + } + else + { + dc2s_scale_h = screen_height / 480.0; + ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2; + //-1 -> too much to left + ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; + ShaderUniforms.scale_coefs[1] = -2.0f / dc_height; + ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width; + ShaderUniforms.scale_coefs[3] = -1; + } ShaderUniforms.depth_coefs[0]=2/(vtx_max_fZ-vtx_min_fZ); ShaderUniforms.depth_coefs[1]=-vtx_min_fZ-1; From 1b04ef4cb11b286e7487683a8283512976579cb5 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 8 Apr 2019 22:09:22 +0200 Subject: [PATCH 29/73] Get rid of RTC in settings --- core/hw/aica/aica.cpp | 7 ++++++- core/hw/aica/aica_if.cpp | 20 +++++++++----------- core/hw/aica/aica_if.h | 3 ++- core/hw/sh4/interpr/sh4_interpreter.cpp | 2 +- core/nullDC.cpp | 3 --- core/types.h | 1 - 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/core/hw/aica/aica.cpp b/core/hw/aica/aica.cpp index 1eea5a03d..3cbf02bd9 100644 --- a/core/hw/aica/aica.cpp +++ b/core/hw/aica/aica.cpp @@ -1,4 +1,5 @@ #include "aica.h" +#include "aica_if.h" #include "sgc_if.h" #include "aica_mem.h" #include @@ -180,6 +181,7 @@ template void WriteAicaReg<2>(u32 reg,u32 data); s32 libAICA_Init() { init_mem(); + aica_Init(); verify(sizeof(*CommonData)==0x508); verify(sizeof(*DSPData)==0x15C8); @@ -203,9 +205,12 @@ s32 libAICA_Init() return rv_ok; } -void libAICA_Reset(bool m) +void libAICA_Reset(bool manual) { + if (!manual) + init_mem(); sgc_Init(); + aica_Reset(manual); } void libAICA_Term() diff --git a/core/hw/aica/aica_if.cpp b/core/hw/aica/aica_if.cpp index c717f8507..9ba65c0a7 100644 --- a/core/hw/aica/aica_if.cpp +++ b/core/hw/aica/aica_if.cpp @@ -18,6 +18,7 @@ u32 VREG;//video reg =P u32 ARMRST;//arm reset reg u32 rtc_EN=0; int dma_sched_id; +u32 RealTimeClock; u32 GetRTC_now() { @@ -39,9 +40,9 @@ u32 ReadMem_aica_rtc(u32 addr,u32 sz) switch( addr & 0xFF ) { case 0: - return settings.dreamcast.RTC>>16; + return RealTimeClock>>16; case 4: - return settings.dreamcast.RTC &0xFFFF; + return RealTimeClock &0xFFFF; case 8: return 0; } @@ -57,16 +58,16 @@ void WriteMem_aica_rtc(u32 addr,u32 data,u32 sz) case 0: if (rtc_EN) { - settings.dreamcast.RTC&=0xFFFF; - settings.dreamcast.RTC|=(data&0xFFFF)<<16; + RealTimeClock&=0xFFFF; + RealTimeClock|=(data&0xFFFF)<<16; rtc_EN=0; } return; case 4: if (rtc_EN) { - settings.dreamcast.RTC&=0xFFFF0000; - settings.dreamcast.RTC|= data&0xFFFF; + RealTimeClock&=0xFFFF0000; + RealTimeClock|= data&0xFFFF; //TODO: Clean the internal timer ? } return; @@ -153,15 +154,12 @@ void WriteMem_aica_reg(u32 addr,u32 data,u32 sz) //Init/res/term void aica_Init() { - //mmnnn ? gotta fill it w/ something + RealTimeClock = GetRTC_now(); } void aica_Reset(bool Manual) { - if (!Manual) - { - aica_ram.Zero(); - } + aica_Init(); } void aica_Term() diff --git a/core/hw/aica/aica_if.h b/core/hw/aica/aica_if.h index 8c6009a66..8c58b5326 100644 --- a/core/hw/aica/aica_if.h +++ b/core/hw/aica/aica_if.h @@ -3,6 +3,7 @@ extern u32 VREG; extern VArray2 aica_ram; +extern u32 RealTimeClock; u32 ReadMem_aica_rtc(u32 addr,u32 sz); void WriteMem_aica_rtc(u32 addr,u32 data,u32 sz); u32 ReadMem_aica_reg(u32 addr,u32 sz); @@ -17,4 +18,4 @@ void aica_Term(); void aica_sb_Init(); void aica_sb_Reset(bool Manual); -void aica_sb_Term(); \ No newline at end of file +void aica_sb_Term(); diff --git a/core/hw/sh4/interpr/sh4_interpreter.cpp b/core/hw/sh4/interpr/sh4_interpreter.cpp index ddc7d509c..5f48886a2 100644 --- a/core/hw/sh4/interpr/sh4_interpreter.cpp +++ b/core/hw/sh4/interpr/sh4_interpreter.cpp @@ -232,7 +232,7 @@ int AicaUpdate(int tag, int c, int j) int DreamcastSecond(int tag, int c, int j) { - settings.dreamcast.RTC++; + RealTimeClock++; #if 1 //HOST_OS==OS_WINDOWS prof_periodical(); diff --git a/core/nullDC.cpp b/core/nullDC.cpp index dbbfe5325..ffc4d524f 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -313,7 +313,6 @@ int dc_start_game(const char *path) { InitSettings(); LoadSettings(false); - settings.dreamcast.RTC = GetRTC_now(); // FIXME This shouldn't be in settings anymore #if DC_PLATFORM == DC_PLATFORM_DREAMCAST if (!settings.bios.UseReios) #endif @@ -351,7 +350,6 @@ int dc_start_game(const char *path) return 0; } - settings.dreamcast.RTC = GetRTC_now(); // FIXME This shouldn't be in settings anymore if (settings.bios.UseReios || !LoadRomFiles(get_readonly_data_path(DATA_PATH))) { #ifdef USE_REIOS @@ -491,7 +489,6 @@ void dc_exit() void InitSettings() { - settings.dreamcast.RTC = GetRTC_now(); settings.dynarec.Enable = true; settings.dynarec.idleskip = true; settings.dynarec.unstable_opt = false; diff --git a/core/types.h b/core/types.h index 2479fef25..c04f79442 100644 --- a/core/types.h +++ b/core/types.h @@ -656,7 +656,6 @@ struct settings_t struct { u32 cable; // 0 -> VGA, 1 -> VGA, 2 -> RGB, 3 -> TV - u32 RTC; u32 region; // 0 -> JP, 1 -> USA, 2 -> EU, 3 -> default u32 broadcast; // 0 -> NTSC, 1 -> PAL, 2 -> PAL/M, 3 -> PAL/N, 4 -> default u32 language; // 0 -> JP, 1 -> EN, 2 -> DE, 3 -> FR, 4 -> SP, 5 -> IT, 6 -> default From 37a533740bfbc056e03486bbf59f7ce01fffaf52 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 9 Apr 2019 10:37:49 +0200 Subject: [PATCH 30/73] win32: close thread handle when finished --- core/windows/winmain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 68db4682c..b2a90b8ed 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -749,6 +749,7 @@ cThread::cThread(ThreadEntryFP* function,void* prm) void cThread::Start() { + verify(hThread == NULL); hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Entry,param,0,NULL); ResumeThread(hThread); } @@ -756,6 +757,8 @@ void cThread::Start() void cThread::WaitToEnd() { WaitForSingleObject(hThread,INFINITE); + CloseHandle(hThread); + hThread = NULL; } //End thread class From 1fa052987bebbfe58ea3b7ec28f6b8581fa340fb Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 9 Apr 2019 10:39:29 +0200 Subject: [PATCH 31/73] android: run renderer in a separate native thread fixes simultaneous gamepad button presses not being registered on some platforms --- .../java/com/reicast/emulator/emu/JNIdc.java | 3 +- .../reicast/emulator/emu/NativeGLView.java | 24 +------ .../reicast/src/main/jni/src/Android.cpp | 71 ++++++++++++------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/JNIdc.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/JNIdc.java index 6262fb27a..fef8b9dfa 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/JNIdc.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/JNIdc.java @@ -21,8 +21,7 @@ public final class JNIdc public static native int send(int cmd, int opt); public static native int data(int cmd, byte[] data); - public static native void rendinitNative(Surface surface, int w, int h); - public static native boolean rendframeNative(); + public static native void rendinitNative(Surface surface); public static native void rendinitJava(int w, int h); public static native boolean rendframeJava(); public static native void rendtermJava(); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/NativeGLView.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/NativeGLView.java index 3a7268401..383a8684a 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/NativeGLView.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/NativeGLView.java @@ -19,8 +19,6 @@ import com.reicast.emulator.NativeGLActivity; import com.reicast.emulator.config.Config; public class NativeGLView extends SurfaceView implements SurfaceHolder.Callback { - private Handler handler = new Handler(); - private boolean surfaceReady = false; private boolean paused = false; VirtualJoystickDelegate vjoyDelegate; @@ -66,23 +64,6 @@ public class NativeGLView extends SurfaceView implements SurfaceHolder.Callback if (NativeGLActivity.syms != null) JNIdc.data(1, NativeGLActivity.syms); - - startRendering(); - } - - private void startRendering() { - // Continuously render frames - handler.removeCallbacksAndMessages(null); - handler.postAtTime(new Runnable() { - @Override - public void run() { - if (!paused) - { - JNIdc.rendframeNative(); - handler.post(this); - } - } - }, SystemClock.uptimeMillis() + 500); } @Override @@ -111,7 +92,7 @@ public class NativeGLView extends SurfaceView implements SurfaceHolder.Callback public void surfaceChanged(SurfaceHolder surfaceHolder, int format, int w, int h) { //Log.i("reicast", "NativeGLView.surfaceChanged: " + w + "x" + h); surfaceReady = true; - JNIdc.rendinitNative(surfaceHolder.getSurface(), w, h); + JNIdc.rendinitNative(surfaceHolder.getSurface()); Emulator.getCurrentActivity().handleStateChange(false); } @@ -119,7 +100,7 @@ public class NativeGLView extends SurfaceView implements SurfaceHolder.Callback public void surfaceDestroyed(SurfaceHolder surfaceHolder) { //Log.i("reicast", "NativeGLView.surfaceDestroyed"); surfaceReady = false; - JNIdc.rendinitNative(null, 0, 0); + JNIdc.rendinitNative(null); Emulator.getCurrentActivity().handleStateChange(true); } @@ -142,7 +123,6 @@ public class NativeGLView extends SurfaceView implements SurfaceHolder.Callback requestFocus(); JNIdc.resume(); } - startRendering(); } @TargetApi(19) diff --git a/shell/android-studio/reicast/src/main/jni/src/Android.cpp b/shell/android-studio/reicast/src/main/jni/src/Android.cpp index 3ab96e5dd..ced2f366d 100644 --- a/shell/android-studio/reicast/src/main/jni/src/Android.cpp +++ b/shell/android-studio/reicast/src/main/jni/src/Android.cpp @@ -91,8 +91,7 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_destroy(JNIEnv *env,j JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_send(JNIEnv *env,jobject obj,jint id, jint v) __attribute__((visibility("default"))); JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_data(JNIEnv *env,jobject obj,jint id, jbyteArray d) __attribute__((visibility("default"))); -JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinitNative(JNIEnv *env, jobject obj, jobject surface, jint w, jint h) __attribute__((visibility("default"))); -JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_rendframeNative(JNIEnv *env,jobject obj) __attribute__((visibility("default"))); +JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinitNative(JNIEnv *env, jobject obj, jobject surface) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinitJava(JNIEnv *env, jobject obj, jint w, jint h) __attribute__((visibility("default"))); JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_rendframeJava(JNIEnv *env, jobject obj) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendtermJava(JNIEnv *env, jobject obj) __attribute__((visibility("default"))); @@ -404,35 +403,57 @@ JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_data(JNIEnv *env, job extern void gl_swap(); extern void egl_stealcntx(); +volatile static bool render_running; +volatile static bool render_reinit; -JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_rendframeNative(JNIEnv *env,jobject obj) +void *render_thread_func(void *) { - if (g_window == NULL) - return false; - if (!egl_makecurrent()) - return false; - jboolean ret = (jboolean)rend_single_frame(); - if (ret) - gl_swap(); - return ret; + render_running = true; + + rend_init_renderer(); + + while (render_running) { + if (render_reinit) + { + render_reinit = false; + rend_init_renderer(); + } + else + if (!egl_makecurrent()) + break;; + + bool ret = rend_single_frame(); + if (ret) + gl_swap(); + } + egl_makecurrent(); + rend_term_renderer(); + ANativeWindow_release(g_window); + g_window = NULL; + render_running = false; + + return NULL; } -JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinitNative(JNIEnv * env, jobject obj, jobject surface, jint width, jint height) +static cThread render_thread(render_thread_func, NULL); + +JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinitNative(JNIEnv * env, jobject obj, jobject surface) { - if (g_window != NULL) - { - egl_makecurrent(); - rend_term_renderer(); - ANativeWindow_release(g_window); - g_window = NULL; - } - if (surface != NULL) - { + if (render_thread.hThread != NULL) + { + if (surface == NULL) + { + render_running = false; + render_thread.WaitToEnd(); + } + else + render_reinit = true; + } + else if (surface != NULL) + { g_window = ANativeWindow_fromSurface(env, surface); - rend_init_renderer(); - screen_width = width; - screen_height = height; - } + render_thread.Start(); + } } JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinitJava(JNIEnv * env, jobject obj, jint width, jint height) From 251b4d381d8da7a57b559f4b198ef4a653715974 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 9 Apr 2019 13:09:45 +0200 Subject: [PATCH 32/73] android: add activity alias for intents backward-compatibility --- .../reicast/src/dreamcast/AndroidManifest.xml | 51 +++++++++++++++ .../reicast/src/main/AndroidManifest.xml | 10 +++ .../reicast/src/naomi/AndroidManifest.xml | 63 ++++++++++++++++++- 3 files changed, 123 insertions(+), 1 deletion(-) diff --git a/shell/android-studio/reicast/src/dreamcast/AndroidManifest.xml b/shell/android-studio/reicast/src/dreamcast/AndroidManifest.xml index 165b7b014..112f56962 100644 --- a/shell/android-studio/reicast/src/dreamcast/AndroidManifest.xml +++ b/shell/android-studio/reicast/src/dreamcast/AndroidManifest.xml @@ -52,5 +52,56 @@ android:scheme="file" /> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shell/android-studio/reicast/src/main/AndroidManifest.xml b/shell/android-studio/reicast/src/main/AndroidManifest.xml index de600f7bc..ac89e2bb2 100644 --- a/shell/android-studio/reicast/src/main/AndroidManifest.xml +++ b/shell/android-studio/reicast/src/main/AndroidManifest.xml @@ -61,6 +61,16 @@ + + + + + + + + + android:name="com.reicast.emulator.NativeGLActivity"> @@ -62,5 +62,66 @@ android:scheme="file" /> + + + + + + + + + + + + + + + + + + + From 0445542ec240e806c753eb20a3710d2f41d9c284 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 9 Apr 2019 15:18:48 +0200 Subject: [PATCH 33/73] gl: 90deg screen rotation option. Fix scissor/clip wrt scale/stretch 90deg CC screen rotation option for some arcade games Fix scissoring and clipping when screen scaling/stretching/rotating Clear shader cache when screen rotation changes Properly delete all gl programs and shaders when needed --- core/nullDC.cpp | 3 + core/rend/gl4/abuffer.cpp | 19 ++++- core/rend/gl4/gl4.h | 4 +- core/rend/gl4/gldraw.cpp | 7 +- core/rend/gl4/gles.cpp | 87 ++++++++++++++++------ core/rend/gles/glcache.h | 13 ++++ core/rend/gles/gldraw.cpp | 31 ++++++-- core/rend/gles/gles.cpp | 103 ++++++++++++++++++-------- core/rend/gles/gles.h | 1 + core/rend/gles/imgui_impl_opengl3.cpp | 8 +- core/rend/gui.cpp | 10 ++- core/types.h | 1 + 12 files changed, 211 insertions(+), 76 deletions(-) diff --git a/core/nullDC.cpp b/core/nullDC.cpp index ffc4d524f..3baf42fa8 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -519,6 +519,7 @@ void InitSettings() settings.rend.ScreenStretching = 100; settings.rend.Fog = true; settings.rend.FloatVMUs = false; + settings.rend.Rotate90 = false; settings.pvr.ta_skip = 0; settings.pvr.rend = 0; @@ -604,6 +605,7 @@ void LoadSettings(bool game_specific) settings.rend.ScreenStretching = cfgLoadInt(config_section, "rend.ScreenStretching", settings.rend.ScreenStretching); settings.rend.Fog = cfgLoadBool(config_section, "rend.Fog", settings.rend.Fog); settings.rend.FloatVMUs = cfgLoadBool(config_section, "rend.FloatVMUs", settings.rend.FloatVMUs); + settings.rend.Rotate90 = cfgLoadBool(config_section, "rend.Rotate90", settings.rend.Rotate90); settings.pvr.ta_skip = cfgLoadInt(config_section, "ta.skip", settings.pvr.ta_skip); settings.pvr.rend = cfgLoadInt(config_section, "pvr.rend", settings.pvr.rend); @@ -730,6 +732,7 @@ void SaveSettings() cfgSaveInt("config", "rend.ScreenStretching", settings.rend.ScreenStretching); cfgSaveBool("config", "rend.Fog", settings.rend.Fog); cfgSaveBool("config", "rend.FloatVMUs", settings.rend.FloatVMUs); + cfgSaveBool("config", "rend.Rotate90", settings.rend.Rotate90); cfgSaveInt("config", "ta.skip", settings.pvr.ta_skip); cfgSaveInt("config", "pvr.rend", settings.pvr.rend); diff --git a/core/rend/gl4/abuffer.cpp b/core/rend/gl4/abuffer.cpp index b09cc962d..7e9b67c64 100644 --- a/core/rend/gl4/abuffer.cpp +++ b/core/rend/gl4/abuffer.cpp @@ -331,23 +331,23 @@ void initABuffer() { char source[16384]; sprintf(source, final_shader_source, 1); - gl4CompilePipelineShader(&g_abuffer_final_shader, source); + gl4CompilePipelineShader(&g_abuffer_final_shader, false, source); } if (g_abuffer_final_nosort_shader.program == 0) { char source[16384]; sprintf(source, final_shader_source, 0); - gl4CompilePipelineShader(&g_abuffer_final_nosort_shader, source); + gl4CompilePipelineShader(&g_abuffer_final_nosort_shader, false, source); } if (g_abuffer_clear_shader.program == 0) - gl4CompilePipelineShader(&g_abuffer_clear_shader, clear_shader_source); + gl4CompilePipelineShader(&g_abuffer_clear_shader, false, clear_shader_source); if (g_abuffer_tr_modvol_shaders[0].program == 0) { char source[16384]; for (int mode = 0; mode < ModeCount; mode++) { sprintf(source, tr_modvol_shader_source, mode); - gl4CompilePipelineShader(&g_abuffer_tr_modvol_shaders[mode], source); + gl4CompilePipelineShader(&g_abuffer_tr_modvol_shaders[mode], false, source); } } @@ -417,6 +417,17 @@ void termABuffer() glDeleteBuffers(1, &g_quadBuffer); g_quadBuffer = 0; } + glcache.DeleteProgram(g_abuffer_final_shader.program); + g_abuffer_final_shader.program = 0; + glcache.DeleteProgram(g_abuffer_final_nosort_shader.program); + g_abuffer_final_nosort_shader.program = 0; + glcache.DeleteProgram(g_abuffer_clear_shader.program); + g_abuffer_clear_shader.program = 0; + for (int mode = 0; mode < ModeCount; mode++) + { + glcache.DeleteProgram(g_abuffer_tr_modvol_shaders[mode].program); + g_abuffer_tr_modvol_shaders[mode].program = 0; + } } void reshapeABuffer(int w, int h) diff --git a/core/rend/gl4/gl4.h b/core/rend/gl4/gl4.h index 5ca4dd141..4c3ca82ac 100755 --- a/core/rend/gl4/gl4.h +++ b/core/rend/gl4/gl4.h @@ -45,6 +45,7 @@ struct gl4_ctx } modvol_shader; std::unordered_map shaders; + bool rotate90; struct { @@ -66,7 +67,8 @@ bool gl4_render_output_framebuffer(); void abufferDrawQuad(bool upsideDown = false, float x = 0.f, float y = 0.f, float w = 0.f, float h = 0.f); extern const char *gl4PixelPipelineShader; -bool gl4CompilePipelineShader(gl4PipelineShader* s, const char *source = gl4PixelPipelineShader); +bool gl4CompilePipelineShader(gl4PipelineShader* s, bool rotate_90, const char *source = gl4PixelPipelineShader); +void gl4_delete_shaders(); extern GLuint stencilTexId; extern GLuint depthTexId; diff --git a/core/rend/gl4/gldraw.cpp b/core/rend/gl4/gldraw.cpp index 75ad7eda9..dfa403a19 100644 --- a/core/rend/gl4/gldraw.cpp +++ b/core/rend/gl4/gldraw.cpp @@ -49,6 +49,11 @@ static gl4PipelineShader *gl4GetProgram(u32 cp_AlphaTest, u32 pp_ClipTestMode, u32 pp_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset, u32 pp_FogCtrl, bool pp_TwoVolumes, u32 pp_DepthFunc, bool pp_Gouraud, bool pp_BumpMap, bool fog_clamping, int pass) { + if (settings.rend.Rotate90 != gl4.rotate90) + { + gl4_delete_shaders(); + gl4.rotate90 = settings.rend.Rotate90; + } u32 rv=0; rv|=pp_ClipTestMode; @@ -83,7 +88,7 @@ static gl4PipelineShader *gl4GetProgram(u32 cp_AlphaTest, u32 pp_ClipTestMode, shader->pp_BumpMap = pp_BumpMap; shader->fog_clamping = fog_clamping; shader->pass = pass; - gl4CompilePipelineShader(shader); + gl4CompilePipelineShader(shader, settings.rend.Rotate90); } return shader; diff --git a/core/rend/gl4/gles.cpp b/core/rend/gl4/gles.cpp index 73330cc66..aa2da9c99 100644 --- a/core/rend/gl4/gles.cpp +++ b/core/rend/gl4/gles.cpp @@ -14,6 +14,7 @@ static const char* VertexShaderSource = "\ #version 140 \n\ #define pp_Gouraud %d \n\ +#define ROTATE_90 %d \n\ \n\ #if pp_Gouraud == 0 \n\ #define INTERPOLATION flat \n\ @@ -56,6 +57,9 @@ void main() \n\ \n\ vpos.w = extra_depth_scale / vpos.z; \n\ vpos.z = vpos.w; \n\ +#if ROTATE_90 == 1 \n\ + vpos.xy = vec2(vpos.y, -vpos.x); \n\ +#endif \n\ vpos.xy=vpos.xy*scale.xy-scale.zw; \n\ vpos.xy*=vpos.w; \n\ gl_Position = vpos; \n\ @@ -393,11 +397,11 @@ gl4_ctx gl4; struct gl4ShaderUniforms_t gl4ShaderUniforms; -bool gl4CompilePipelineShader( gl4PipelineShader* s, const char *source /* = PixelPipelineShader */) +bool gl4CompilePipelineShader( gl4PipelineShader* s, bool rotate_90, const char *source /* = PixelPipelineShader */) { char vshader[16384]; - sprintf(vshader, VertexShaderSource, s->pp_Gouraud); + sprintf(vshader, VertexShaderSource, s->pp_Gouraud, rotate_90); char pshader[16384]; @@ -478,27 +482,45 @@ bool gl4CompilePipelineShader( gl4PipelineShader* s, const char *source /* = Pix void gl_term(); +void gl4_delete_shaders() +{ + for (auto it : gl4.shaders) + { + if (it.second.program != 0) + glcache.DeleteProgram(it.second.program); + } + gl4.shaders.clear(); + glcache.DeleteProgram(gl4.modvol_shader.program); + gl4.modvol_shader.program = 0; +} + static void gles_term(void) { - glDeleteProgram(gl4.modvol_shader.program); glDeleteBuffers(1, &gl4.vbo.geometry); gl4.vbo.geometry = 0; glDeleteBuffers(1, &gl4.vbo.modvols); glDeleteBuffers(1, &gl4.vbo.idxs); glDeleteBuffers(1, &gl4.vbo.idxs2); glDeleteBuffers(1, &gl4.vbo.tr_poly_params); - for (auto it = gl4.shaders.begin(); it != gl4.shaders.end(); it++) - { - if (it->second.program != 0) - glDeleteProgram(it->second.program); - } - gl4.shaders.clear(); + gl4_delete_shaders(); glDeleteVertexArrays(1, &gl4.vbo.main_vao); glDeleteVertexArrays(1, &gl4.vbo.modvol_vao); gl_term(); } +static void create_modvol_shader() +{ + if (gl4.modvol_shader.program != 0) + return; + char vshader[16384]; + sprintf(vshader, VertexShaderSource, 1, settings.rend.Rotate90); + + gl4.modvol_shader.program=gl_CompileAndLink(vshader, ModifierVolumeShader); + gl4.modvol_shader.scale = glGetUniformLocation(gl4.modvol_shader.program, "scale"); + gl4.modvol_shader.extra_depth_scale = glGetUniformLocation(gl4.modvol_shader.program, "extra_depth_scale"); +} + static bool gl_create_resources() { if (gl4.vbo.geometry != 0) @@ -520,12 +542,7 @@ static bool gl_create_resources() gl4SetupMainVBO(); gl4SetupModvolVBO(); - char vshader[16384]; - sprintf(vshader, VertexShaderSource, 1); - - gl4.modvol_shader.program=gl_CompileAndLink(vshader, ModifierVolumeShader); - gl4.modvol_shader.scale = glGetUniformLocation(gl4.modvol_shader.program, "scale"); - gl4.modvol_shader.extra_depth_scale = glGetUniformLocation(gl4.modvol_shader.program, "extra_depth_scale"); + create_modvol_shader(); gl_load_osd_resources(); @@ -603,6 +620,7 @@ static bool RenderFrame() old_screen_scaling = settings.rend.ScreenScaling; } DoCleanup(); + create_modvol_shader(); bool is_rtt=pvrrc.isRTT; @@ -676,13 +694,25 @@ static bool RenderFrame() } else { - dc2s_scale_h = screen_height / 480.0; - ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2; - //-1 -> too much to left - gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; - gl4ShaderUniforms.scale_coefs[1] = -2.0f / dc_height; - gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width; - gl4ShaderUniforms.scale_coefs[3] = -1; + if (settings.rend.Rotate90) + { + dc2s_scale_h = screen_height / 640.0; + ds2s_offs_x = (screen_width - dc2s_scale_h * 480.0 * screen_stretching) / 2; + gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; + gl4ShaderUniforms.scale_coefs[1] = -2.0f / dc_width; + gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width; + gl4ShaderUniforms.scale_coefs[3] = 1; + } + else + { + dc2s_scale_h = screen_height / 480.0; + ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2; + //-1 -> too much to left + gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; + gl4ShaderUniforms.scale_coefs[1] = -2.0f / dc_height; + gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width; + gl4ShaderUniforms.scale_coefs[3] = -1; + } } gl4ShaderUniforms.extra_depth_scale = settings.rend.ExtraDepthScale; @@ -838,11 +868,20 @@ static bool RenderFrame() float min_y = pvrrc.fb_Y_CLIP.min / scale_y; if (!is_rtt) { + if (settings.rend.Rotate90) + { + float t = width; + width = height; + height = t; + t = min_x; + min_x = min_y; + min_y = 640 - t - height; + } // Add x offset for aspect ratio > 4/3 - min_x = min_x * dc2s_scale_h * screen_stretching + ds2s_offs_x * screen_scaling; + min_x = (min_x * dc2s_scale_h * screen_stretching + ds2s_offs_x) * screen_scaling; // Invert y coordinates when rendering to screen min_y = (screen_height - (min_y + height) * dc2s_scale_h) * screen_scaling; - width *= dc2s_scale_h * screen_scaling * screen_stretching; + width *= dc2s_scale_h * screen_stretching * screen_scaling; height *= dc2s_scale_h * screen_scaling; if (ds2s_offs_x > 0) diff --git a/core/rend/gles/glcache.h b/core/rend/gles/glcache.h index e245a368d..32c73c644 100644 --- a/core/rend/gles/glcache.h +++ b/core/rend/gles/glcache.h @@ -149,6 +149,19 @@ public: return _texture_ids[--_texture_cache_size]; } + void DeleteProgram(GLuint program) + { + GLsizei shader_count; + GLuint shaders[2]; + glGetAttachedShaders(program, ARRAY_SIZE(shaders), &shader_count, shaders); + for (int i = 0; i < shader_count; i++) + glDeleteShader(shaders[i]); + + glDeleteProgram(program); + if (_program == program) + _program = 0; + } + void Reset() { _texture = 0xFFFFFFFFu; _src_blend_factor = 0xFFFFFFFFu; diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index 618a3e33f..b4381170d 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -114,13 +114,30 @@ s32 SetTileClip(u32 val, GLint uniform) csy /= scale_y; cex /= scale_x; cey /= scale_y; - float t = cey; - cey = 480 - csy; - csy = 480 - t; - float dc2s_scale_h = screen_height / 480.0f; - float ds2s_offs_x = (screen_width - dc2s_scale_h * 640) / 2; - csx = csx * dc2s_scale_h + ds2s_offs_x; - cex = cex * dc2s_scale_h + ds2s_offs_x; + float dc2s_scale_h; + float ds2s_offs_x; + float screen_stretching = settings.rend.ScreenStretching / 100.f; + + if (settings.rend.Rotate90) + { + float t = cex; + cex = cey; + cey = 640 - csx; + csx = csy; + csy = 640 - t; + dc2s_scale_h = screen_height / 640.0f; + ds2s_offs_x = (screen_width - dc2s_scale_h * 480.0 * screen_stretching) / 2; + } + else + { + float t = cey; + cey = 480 - csy; + csy = 480 - t; + dc2s_scale_h = screen_height / 480.0f; + ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2; + } + csx = csx * dc2s_scale_h * screen_stretching + ds2s_offs_x; + cex = cex * dc2s_scale_h * screen_stretching + ds2s_offs_x; csy = csy * dc2s_scale_h; cey = cey * dc2s_scale_h; } diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index b16274d99..a2155f460 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -79,6 +79,7 @@ const char* VertexShaderSource = %s \n\ #define TARGET_GL %s \n\ #define pp_Gouraud %d \n\ +#define ROTATE_90 %d \n\ \n\ #define GLES2 0 \n\ #define GLES3 1 \n\ @@ -136,6 +137,9 @@ void main() \n\ vpos.z = vpos.w; \n\ #else \n\ vpos.z=depth_scale.x+depth_scale.y*vpos.w; \n\ +#endif \n\ +#if ROTATE_90 == 1 \n\ + vpos.xy = vec2(vpos.y, -vpos.x); \n\ #endif \n\ vpos.xy=vpos.xy*scale.xy-scale.zw; \n\ vpos.xy*=vpos.w; \n\ @@ -850,9 +854,20 @@ GLuint fogTextureId; extern void gl_term(); #endif +static void gl_delete_shaders() +{ + for (auto it : gl.shaders) + { + if (it.second.program != 0) + glcache.DeleteProgram(it.second.program); + } + gl.shaders.clear(); + glcache.DeleteProgram(gl.modvol_shader.program); + gl.modvol_shader.program = 0; +} + static void gles_term() { - glDeleteProgram(gl.modvol_shader.program); glDeleteBuffers(1, &gl.vbo.geometry); gl.vbo.geometry = 0; glDeleteBuffers(1, &gl.vbo.modvols); @@ -865,7 +880,7 @@ static void gles_term() gl_free_osd_resources(); free_output_framebuffer(); - gl.shaders.clear(); + gl_delete_shaders(); gl_term(); } @@ -1018,6 +1033,11 @@ PipelineShader *GetProgram(u32 cp_AlphaTest, u32 pp_ClipTestMode, u32 pp_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset, u32 pp_FogCtrl, bool pp_Gouraud, bool pp_BumpMap, bool fog_clamping, bool trilinear) { + if (settings.rend.Rotate90 != gl.rotate90) + { + gl_delete_shaders(); + gl.rotate90 = settings.rend.Rotate90; + } u32 rv=0; rv|=pp_ClipTestMode; @@ -1058,7 +1078,7 @@ bool CompilePipelineShader( PipelineShader* s) { char vshader[8192]; - sprintf(vshader, VertexShaderSource, gl.glsl_version_header, gl.gl_version, s->pp_Gouraud); + sprintf(vshader, VertexShaderSource, gl.glsl_version_header, gl.gl_version, s->pp_Gouraud, settings.rend.Rotate90); char pshader[8192]; @@ -1144,13 +1164,30 @@ void gl_load_osd_resources() void gl_free_osd_resources() { - glDeleteProgram(gl.OSD_SHADER.program); + glcache.DeleteProgram(gl.OSD_SHADER.program); if (osd_tex != 0) { glcache.DeleteTextures(1, &osd_tex); osd_tex = 0; } } + +static void create_modvol_shader() +{ + if (gl.modvol_shader.program != 0) + return; + char vshader[8192]; + sprintf(vshader, VertexShaderSource, gl.glsl_version_header, gl.gl_version, 1, settings.rend.Rotate90); + char fshader[8192]; + sprintf(fshader, ModifierVolumeShader, gl.glsl_version_header, gl.gl_version); + + gl.modvol_shader.program=gl_CompileAndLink(vshader, fshader); + gl.modvol_shader.scale = glGetUniformLocation(gl.modvol_shader.program, "scale"); + gl.modvol_shader.sp_ShaderColor = glGetUniformLocation(gl.modvol_shader.program, "sp_ShaderColor"); + gl.modvol_shader.depth_scale = glGetUniformLocation(gl.modvol_shader.program, "depth_scale"); + gl.modvol_shader.extra_depth_scale = glGetUniformLocation(gl.modvol_shader.program, "extra_depth_scale"); +} + bool gl_create_resources() { if (gl.vbo.geometry != 0) @@ -1174,25 +1211,7 @@ bool gl_create_resources() glGenBuffers(1, &gl.vbo.idxs); glGenBuffers(1, &gl.vbo.idxs2); - char vshader[8192]; - sprintf(vshader, VertexShaderSource, gl.glsl_version_header, gl.gl_version, 1); - char fshader[8192]; - sprintf(fshader, ModifierVolumeShader, gl.glsl_version_header, gl.gl_version); - - gl.modvol_shader.program=gl_CompileAndLink(vshader, fshader); - gl.modvol_shader.scale = glGetUniformLocation(gl.modvol_shader.program, "scale"); - gl.modvol_shader.sp_ShaderColor = glGetUniformLocation(gl.modvol_shader.program, "sp_ShaderColor"); - gl.modvol_shader.depth_scale = glGetUniformLocation(gl.modvol_shader.program, "depth_scale"); - gl.modvol_shader.extra_depth_scale = glGetUniformLocation(gl.modvol_shader.program, "extra_depth_scale"); - - //#define PRECOMPILE_SHADERS - #ifdef PRECOMPILE_SHADERS - for (u32 i=0;i too much to left - ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching; - ShaderUniforms.scale_coefs[1] = -2.0f / dc_height; - ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width; - ShaderUniforms.scale_coefs[3] = -1; } ShaderUniforms.depth_coefs[0]=2/(vtx_max_fZ-vtx_min_fZ); @@ -1868,11 +1900,20 @@ bool RenderFrame() float min_y = pvrrc.fb_Y_CLIP.min / scale_y; if (!is_rtt) { + if (settings.rend.Rotate90) + { + float t = width; + width = height; + height = t; + t = min_x; + min_x = min_y; + min_y = 640 - t - height; + } // Add x offset for aspect ratio > 4/3 - min_x = min_x * dc2s_scale_h * screen_stretching + ds2s_offs_x * screen_scaling; + min_x = (min_x * dc2s_scale_h * screen_stretching + ds2s_offs_x) * screen_scaling; // Invert y coordinates when rendering to screen min_y = (screen_height - (min_y + height) * dc2s_scale_h) * screen_scaling; - width *= dc2s_scale_h * screen_scaling * screen_stretching; + width *= dc2s_scale_h * screen_stretching * screen_scaling; height *= dc2s_scale_h * screen_scaling; if (ds2s_offs_x > 0) diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index 7e0cec3cb..85f1b90e8 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -96,6 +96,7 @@ struct gl_ctx } modvol_shader; std::unordered_map shaders; + bool rotate90; struct { diff --git a/core/rend/gles/imgui_impl_opengl3.cpp b/core/rend/gles/imgui_impl_opengl3.cpp index ddb363c1c..0380a8901 100644 --- a/core/rend/gles/imgui_impl_opengl3.cpp +++ b/core/rend/gles/imgui_impl_opengl3.cpp @@ -490,15 +490,9 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects() if (g_ElementsHandle) glDeleteBuffers(1, &g_ElementsHandle); g_VboHandle = g_ElementsHandle = 0; - if (g_ShaderHandle && g_VertHandle) glDetachShader(g_ShaderHandle, g_VertHandle); - if (g_VertHandle) glDeleteShader(g_VertHandle); + glcache.DeleteProgram(g_ShaderHandle); g_VertHandle = 0; - - if (g_ShaderHandle && g_FragHandle) glDetachShader(g_ShaderHandle, g_FragHandle); - if (g_FragHandle) glDeleteShader(g_FragHandle); g_FragHandle = 0; - - if (g_ShaderHandle) glDeleteProgram(g_ShaderHandle); g_ShaderHandle = 0; ImGui_ImplOpenGL3_DestroyFontsTexture(); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 7a0fb107d..c02e81005 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -804,13 +804,14 @@ static void gui_display_settings() if (ImGui::BeginTabItem("Controls")) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding); -#if DC_PLATFORM == DC_PLATFORM_DREAMCAST +#if DC_PLATFORM == DC_PLATFORM_DREAMCAST || DC_PLATFORM == DC_PLATFORM_ATOMISWAVE if (ImGui::CollapsingHeader("Dreamcast Devices", ImGuiTreeNodeFlags_DefaultOpen)) { for (int bus = 0; bus < MAPLE_PORTS; bus++) { ImGui::Text("Device %c", bus + 'A'); ImGui::SameLine(); +#if DC_PLATFORM == DC_PLATFORM_DREAMCAST char device_name[32]; sprintf(device_name, "##device%d", bus); float w = ImGui::CalcItemWidth() / 3; @@ -854,6 +855,10 @@ static void gui_display_settings() ImGui::PopID(); } ImGui::PopItemWidth(); +#elif DC_PLATFORM == DC_PLATFORM_ATOMISWAVE + if (MapleDevices[bus][5] != NULL) + ImGui::Text("%s", maple_device_name(MapleDevices[bus][5]->get_device_type())); +#endif } ImGui::Spacing(); } @@ -966,6 +971,9 @@ static void gui_display_settings() ImGui::Checkbox("Show VMU in game", &settings.rend.FloatVMUs); ImGui::SameLine(); ShowHelpMarker("Show the VMU LCD screens while in game"); + ImGui::Checkbox("Rotate screen 90°", &settings.rend.Rotate90); + ImGui::SameLine(); + ShowHelpMarker("Rotate the screen 90° counterclockwise"); ImGui::SliderInt("Scaling", (int *)&settings.rend.ScreenScaling, 1, 100); ImGui::SameLine(); ShowHelpMarker("Downscaling factor relative to native screen resolution. Higher is better"); diff --git a/core/types.h b/core/types.h index c04f79442..3d48ae574 100644 --- a/core/types.h +++ b/core/types.h @@ -636,6 +636,7 @@ struct settings_t int ScreenStretching; // in percent. 150 means stretch from 4/3 to 6/3 bool Fog; bool FloatVMUs; + bool Rotate90; // Rotate the screen 90 deg CC } rend; struct From 13341ecd597ddb83cc31508d56c068b03f88a7cf Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Wed, 10 Apr 2019 11:31:08 +0200 Subject: [PATCH 34/73] maple: process_kcode -> transform_kcode --- core/hw/maple/maple_devs.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index bb65dde69..90b4c972a 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -208,7 +208,7 @@ struct maple_sega_controller: maple_base return 0xfe060f00; // 4 analog axes (0-3) X Y A B Start U D L R } - virtual u32 process_kcode(u32 kcode) { + virtual u32 transform_kcode(u32 kcode) { return kcode; } @@ -280,7 +280,7 @@ struct maple_sega_controller: maple_base //state data //2 key code - w16(process_kcode(pjs.kcode)); + w16(transform_kcode(pjs.kcode)); //triggers //1 R @@ -322,7 +322,7 @@ struct maple_atomiswave_controller: maple_sega_controller return 0xff663f00; // 6 analog axes, X Y L2/D2(?) A B C Start U D L R } - virtual u32 process_kcode(u32 kcode) override { + virtual u32 transform_kcode(u32 kcode) override { return kcode | AWAVE_TRIGGER_KEY; } @@ -1329,7 +1329,7 @@ struct maple_mouse : maple_base struct maple_lightgun : maple_base { - virtual u32 process_kcode(u32 kcode) { + virtual u32 transform_kcode(u32 kcode) { return kcode | 0xFF01; } @@ -1387,7 +1387,7 @@ struct maple_lightgun : maple_base //state data //2 key code - w16(process_kcode(pjs.kcode)); + w16(transform_kcode(pjs.kcode)); //not used //2 @@ -1415,7 +1415,7 @@ struct maple_lightgun : maple_base struct atomiswave_lightgun : maple_lightgun { - virtual u32 process_kcode(u32 kcode) override { + virtual u32 transform_kcode(u32 kcode) override { return (kcode & AWAVE_TRIGGER_KEY) == 0 ? ~AWAVE_BTN0_KEY : ~0; } }; From cc9d5ec55b1d8c54856a6715362478cf5a2cbd6d Mon Sep 17 00:00:00 2001 From: david miller Date: Fri, 12 Apr 2019 16:59:39 -0400 Subject: [PATCH 35/73] CMake/Master working, tested on windows with Clang && MSC (x86,x64) --- CMakeLists.txt | 313 ++++++++++++ CMakeSettings.json | 216 ++++++++ core/build.h | 36 +- core/hw/modem/dns.cpp | 5 + core/hw/sh4/dyna/blockmanager.h | 5 +- core/hw/sh4/sh4_interpreter.h | 6 +- core/hw/sh4/sh4_sched.cpp | 36 +- core/rend/gl4/gltex.cpp | 2 +- core/rend/gui.cpp | 3 +- core/serialize.cpp | 187 ++++--- core/stdclass.cpp | 6 +- core/types.h | 8 +- core/version.h.in | 8 + core/windows/winmain.cpp | 2 +- shell/cmake/GetGitRevisionDescription.cmake | 168 ++++++ .../cmake/GetGitRevisionDescription.cmake.in | 41 ++ shell/cmake/android.cmake | 101 ++++ shell/cmake/config.cmake | 481 ++++++++++++++++++ shell/cmake/devkitA64.cmake | 41 ++ shell/cmake/ps4sdk.cmake | 130 +++++ shell/reicast.vcxproj | 2 +- 21 files changed, 1662 insertions(+), 135 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 CMakeSettings.json create mode 100644 core/version.h.in create mode 100644 shell/cmake/GetGitRevisionDescription.cmake create mode 100644 shell/cmake/GetGitRevisionDescription.cmake.in create mode 100644 shell/cmake/android.cmake create mode 100644 shell/cmake/config.cmake create mode 100644 shell/cmake/devkitA64.cmake create mode 100644 shell/cmake/ps4sdk.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..49a9a1138 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,313 @@ +cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR) + +set(TNAME reicast) + +project(${TNAME}) + +enable_language(ASM) + +set(DEBUG_CMAKE ON) + +set(CMAKE_VERBOSE_MAKEFILE ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + + +## built-in cmake modules # +# +#include(CheckIncludeFiles) +#include(CheckFunctionExists) +#include(CheckCSourceCompiles) + +#set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin) +#set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) +#set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) + + + +set(reicast_root_path "${CMAKE_CURRENT_SOURCE_DIR}") +set(reicast_core_path "${reicast_root_path}/core") +set(reicast_shell_path "${reicast_root_path}/shell") + +include_directories ("${reicast_core_path}") + +list(APPEND CMAKE_MODULE_PATH "${reicast_shell_path}/cmake") + + +include(GetGitRevisionDescription) +git_describe(GIT_VERSION --tags) +configure_file(${reicast_core_path}/version.h.in ${reicast_core_path}/version.h @ONLY) + + + + +## reicast build modules # +# + +set(reicast_SRCS "") + +include(config) # configure build settings, must be first + + + +### libdreamcast.cmake ######################################################################### + +set(d_core ${reicast_core_path}) + +file(GLOB_RECURSE hw_SRCS ${d_core}/hw/*.cpp ${d_core}/hw/*.h) + +file(GLOB cfg_SRCS ${d_core}/cfg/*.cpp ${d_core}/cfg/*.h) +file(GLOB rend_SRCS ${d_core}/rend/*.cpp ${d_core}/rend/*.h) +file(GLOB input_SRCS ${d_core}/input/*.cpp ${d_core}/input/*.h) +file(GLOB reios_SRCS ${d_core}/reios/*.cpp ${d_core}/reios/*.h) +file(GLOB imgread_SRCS ${d_core}/imgread/*.cpp ${d_core}/imgread/*.h) +file(GLOB profiler_SRCS ${d_core}/profiler/*.cpp ${d_core}/profiler/*.h) +file(GLOB archive_SRCS ${d_core}/archive/*.cpp ${d_core}/archive/*.h) + +#### option(rend) +file(GLOB gl4_SRCS ${d_core}/rend/gl4/*.cpp ${d_core}/rend/gl4/*.h) +file(GLOB gles_SRCS ${d_core}/rend/gles/*.cpp ${d_core}/rend/gles/*.h) + +set(core_SRCS + ${hw_SRCS} + ${cfg_SRCS} + ${rend_SRCS} + ${gl4_SRCS} + ${gles_SRCS} + ${input_SRCS} + ${reios_SRCS} + ${imgread_SRCS} + ${profiler_SRCS} +# ${archive_SRCS} + ${d_core}/archive/archive.cpp ${d_core}/archive/archive.h + ${d_core}/nullDC.cpp + ${d_core}/stdclass.cpp + ${d_core}/dispframe.cpp + ${d_core}/serialize.cpp +) + + +if(${FEAT_SHREC} EQUAL ${DYNAREC_JIT}) +# + if(${HOST_CPU} EQUAL ${CPU_X86}) + list(APPEND core_SRCS + ${d_core}/rec-x86/rec_x86_driver.cpp + ${d_core}/rec-x86/rec_x86_il.cpp + ${d_core}/rec-x86/rec_x86_asm.cpp # change for linux , rec_lin86_asm.S + ${d_core}/rec-x86/rec_x86_ngen.h + ) + elseif(${HOST_CPU} EQUAL ${CPU_ARM}) + list(APPEND core_SRCS + ${d_core}/rec-ARM/ngen_arm.S + ${d_core}/rec-ARM/rec_arm.cpp + ) + elseif(${HOST_CPU} EQUAL ${CPU_X64}) + + ### FIXME: asm with cmake ninja+VC + if(${BUILD_COMPILER} EQUAL ${COMPILER_VC}) + list(APPEND core_SRCS ${d_core}/rec-x64/msvc.asm) + endif() + + list(APPEND core_SRCS ${d_core}/rec-x64/rec_x64.cpp ${d_core}/rec-x64/x64_regalloc.h) + + elseif(${HOST_CPU} EQUAL ${CPU_A64}) + list(APPEND core_SRCS ${d_core}/rec-ARM64/rec_arm64.cpp ${d_core}/rec-ARM64/arm64_regalloc.h) + + else() + message(" FEAT_SHREC==DYNAREC_JIT && HOST_CPU Unknown Default add arch or disable rec if not avail.") + error() + endif() +# +elseif(${FEAT_SHREC} EQUAL ${DYNAREC_CPP}) + list(APPEND core_SRCS ${d_core}/rec-cpp/rec_cpp.cpp) +endif() + +add_definitions(/DFEAT_HAS_SOFTREND=0) + + +### deps.cmake ################################################################################# + +set(d_deps ${reicast_core_path}/deps) +include_directories ("${d_deps}") +include_directories ("${d_deps}/picotcp/include") +include_directories ("${d_deps}/picotcp/modules") + +file(GLOB xbyak_H ${d_deps}/xbyak/*.h) # include headers into cmake target/project view + +file(GLOB chdr_SRCS ${d_deps}/chdr/*.c) +file(GLOB lzma_SRCS ${d_deps}/lzma/*.c) +file(GLOB lz_SRCS ${d_deps}/zlib/*.c) +file(GLOB lzip_SRCS ${d_deps}/libzip/*.c) +file(GLOB lpng_SRCS ${d_deps}/libpng/*.c) +file(GLOB lelf_SRCS ${d_deps}/libelf/el*.cpp) +file(GLOB crypt_SRCS ${d_deps}/crypto/*.cpp) +file(GLOB imgui_SRCS ${d_deps}/imgui/*.cpp) +file(GLOB lws_SRCS ${d_deps}/libwebsocket/*.c) + +file(GLOB picoModS ${d_deps}/picotcp/modules/*.c) +file(GLOB picoStkS ${d_deps}/picotcp/stack/*.c) +set(pico_SRCS ${picoModS} ${picoStkS}) + +set(deps_SRCS + ${lz_SRCS} +# ${lzip_SRCS} +# ${lzma_SRCS} +# ${pico_SRCS} + ${lpng_SRCS} + ${lelf_SRCS} + ${chdr_SRCS} + ${crypt_SRCS} + ${imgui_SRCS} + ${d_deps}/xbrz/xbrz.cpp + ${d_deps}/dirent/dirent.c + ${d_deps}/xxhash/xxhash.c + ${d_deps}/chdpsr/cdipsr.cpp # sigh, this dir is named chdpsr for some reason ... + ${d_deps}/coreio/coreio.cpp +# ${d_deps}/ifaddrs/ifaddrs.c + ${xbyak_H} +) + + + +### libosd.cmake ################################################################################ + + +set(d_aout ${reicast_core_path}/oslib) + +include_directories ("${d_core}/khronos") + +## I really should just glob all of the dirs and ;shrug; if guards don't do it all ## + +set(osd_SRCS "") + +list(APPEND osd_SRCS ${d_aout}/audiostream.cpp) + +if (${HOST_OS} EQUAL ${OS_WINDOWS}) + + list(APPEND osd_SRCS ${d_core}/windows/winmain.cpp) + list(APPEND osd_SRCS ${d_aout}/audiobackend_directsound.cpp) + + + link_libraries(Dsound.lib winmm.lib) + + +elseif (${HOST_OS} EQUAL ${OS_LINUX} OR ${HOST_OS} EQUAL ${OS_ANDROID}) + + list(APPEND osd_SRCS + ${d_core}/linux/common.cpp + ${d_core}/linux/context.cpp + ${d_core}/linux/nixprof/nixprof.cpp + + ${d_aout}/audiobackend_oss.cpp # add option + ) # todo: configure linux audio lib options + + if(NOT ANDROID) + list(APPEND osd_SRCS + ${d_core}/linux-dist/x11.cpp + ${d_core}/linux-dist/main.cpp + ${d_core}/linux-dist/evdev.cpp) + + add_definitions(-DSUPPORT_X11) ## don't use GLES ? + link_libraries(X11) + else() + list(APPEND osd_SRCS + .//android-studio/reicast/src/main/jni/src/Android.cpp + .//android-studio/reicast/src/main/jni/src/utils.cpp + # .//android-studio/reicast/src/main/jni/src/XperiaPlay.c + ) + endif() # ANDROID + + add_definitions(-DGLES -DUSE_EVDEV) + + link_libraries(pthread dl rt asound Xext GLESv2 EGL) + +elseif(${HOST_OS} EQUAL ${OS_DARWIN}) +# + list(APPEND objc_SRCS + ./shell/apple/emulator-osx/emulator-osx/osx-main.mm + ./shell/apple/emulator-osx/emulator-osx/AppDelegate.swift + ./shell/apple/emulator-osx/emulator-osx/EmuGLView.swift + ) + + set_source_files_properties(${objc_SRCS} PROPERTIES COMPILE_FLAGS "-x objective-c++") + + list(APPEND osd_SRCS ${objc_SRCS} + ${d_osd}/linux/common.cpp + ${d_osd}/linux/context.cpp + ${d_osd}/audiobackend/audiobackend_coreaudio.cpp + # if NOT USE_SWIFT / ObjC + #${d_osd}/apple/osx_osd.cpp + ) + +else() +# + message("OS Unhandled") + error() +# +endif() + + + + + +set(reicast_SRCS ${core_SRCS} ${deps_SRCS} ${osd_SRCS}) + +add_executable(${TNAME}${binSuffix} ${reicast_SRCS} ${deps_SRCS}) + + + + + +if(APPLE) + enable_language(Swift) + set_property(TARGET ${TNAME} PROPERTY XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "./shell/apple/emulator-osx/emulator-osx/emulator-osx-Bridging-Header.h") + + target_link_libraries(${TNAME} +# "-framework Cocoa" +# "-framework AppKit" + "-framework CoreData" + "-framework CoreAudio" + "-framework AudioUnit" + "-framework AudioToolbox" + "-framework Foundation" +) + +#### OSX Notes, when not using xcode you have to make app bundle, edit plist and copy, convert MainMenu.xib to nib and copy, +#null@devpc:~$ /Users/null/Documents/projects/reicast-emulator/bin/RelWithDebInfo/Reicast.app/Contents/MacOS/reicast ; exit; +#2019-03-18 14:28:44.842 reicast[11468:131797] Unknown class _TtC12emulator_osx9EmuGLView in Interface Builder file at path /Users/null/Documents/projects/reicast-emulator/bin/RelWithDebInfo/Reicast.app/Contents/Resources/MainMenu.nib. +#2019-03-18 14:28:44.842 reicast[11468:131797] Unknown class _TtC12emulator_osx11AppDelegate in Interface Builder file at path /Users/null/Documents/projects/reicast-emulator/bin/RelWithDebInfo/Reicast.app/Contents/Resources/MainMenu.nib. +#2019-03-18 14:28:44.860 reicast[11468:131797] Failed to connect (window) outlet from (NSObject) to (NSWindow): missing setter or instance variable +# + +endif() #APPLE + + +if(DEBUG_CMAKE) + message(" ------------------------------------------------") + message(" - HOST_OS: ${HOST_OS} - HOST_CPU: ${HOST_CPU} ") + message(" - host_os: ${host_os} - host_arch: ${host_arch} ") + message(" ------------------------------------------------") + message(" C Flags: ${CMAKE_C_FLAGS} ") + message(" CXX Flags: ${CMAKE_CXX_FLAGS} ") + message(" LINK_DIRS: ${LINK_DIRECTORIES}") + message("LINK_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") + message(" ------------------------------------------------\n") +endif() + + + + + + + + + + + + + + + + + + + diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 000000000..8ddfb307d --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,216 @@ +{ + "environments": [ + { + "environment": "toolchain.generic", + "TOOLCHAIN_FILE": "ps4sdk.cmake" + } + ], + "configurations": [ + { + "name": "win-x86-Debug", + "generator": "Ninja", + "description": "TemplateDescription_Localize_x86Debug", + "configurationType": "Debug", + "inheritEnvironments": [ + "msvc_x86" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + }, + { + "name": "win-x86-Release", + "generator": "Ninja", + "description": "TemplateDescription_Localize_x86Release", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "msvc_x86" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + }, + { + "name": "win-x64-Debug", + "generator": "Ninja", + "description": "TemplateDescription_Localize_x64Debug", + "configurationType": "Debug", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "-DNINJA=1", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + }, + { + "name": "win-x64-Release", + "generator": "Ninja", + "description": "TemplateDescription_Localize_x64Release", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "-DNINJA=1", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + }, + { + "name": "win-x64-Clang-RelWithDebInfo", + "generator": "Ninja", + "description": "TemplateDescription_Localize_x64Release", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "variables": [ + { + "name": "CMAKE_C_COMPILER", + "value": "clang-cl.exe" + }, + { + "name": "CMAKE_CXX_COMPILER", + "value": "clang-cl.exe" + } + ] + }, + { + "name": "PS4 SDK", + "generator": "Ninja", + "description": "TemplateDescription_Localize_PS4SDK", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "toolchain.generic" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "-DCMAKE_TOOLCHAIN_FILE=${projectDir}\\cmake\\ps4sdk.cmake", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + }, + { + "name": "NSW SDK", + "generator": "Ninja", + "description": "TemplateDescription_Localize_PS4SDK", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "toolchain.generic" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "-DCMAKE_TOOLCHAIN_FILE=${projectDir}\\cmake\\devkitA64.cmake", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + }, + { + "name": "uwp-x64-Release", + "generator": "Visual Studio 15 2017 Win64", + "description": "TemplateDescription_Localize_x64Release", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10", + "buildCommandArgs": "", + "ctestCommandArgs": "" + }, + { + "name": "win-x64-MSBuild-Release", + "generator": "Visual Studio 15 2017 Win64", + "description": "TemplateDescription_Localize_x64Release", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "" + }, + { + "environments": [ + { + "MINGW64_ROOT": "C:\\msys64\\mingw64", + "BIN_ROOT": "${env.MINGW64_ROOT}\\bin", + "FLAVOR": "x86_64-w64-mingw32", + "TOOLSET_VERSION": "7.3.0", + "PATH": "${env.MINGW64_ROOT}\\bin;${env.MINGW64_ROOT}\\..\\usr\\local\\bin;${env.MINGW64_ROOT}\\..\\usr\\bin;${env.MINGW64_ROOT}\\..\\bin;${env.PATH}", + "INCLUDE": "${env.INCLUDE};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\tr1;${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\${env.FLAVOR}", + "environment": "mingw_64" + } + ], + "name": "Mingw64-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "mingw_64" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "intelliSenseMode": "linux-gcc-x64", + "variables": [ + { + "name": "CMAKE_C_COMPILER", + "value": "${env.BIN_ROOT}\\gcc.exe" + }, + { + "name": "CMAKE_CXX_COMPILER", + "value": "${env.BIN_ROOT}\\g++.exe" + } + ] + }, + { + "environments": [ + { + "MINGW64_ROOT": "C:\\msys64\\mingw64", + "BIN_ROOT": "${env.MINGW64_ROOT}\\bin", + "FLAVOR": "x86_64-w64-mingw32", + "TOOLSET_VERSION": "7.3.0", + "PATH": "${env.MINGW64_ROOT}\\bin;${env.MINGW64_ROOT}\\..\\usr\\local\\bin;${env.MINGW64_ROOT}\\..\\usr\\bin;${env.MINGW64_ROOT}\\..\\bin;${env.PATH}", + "INCLUDE": "${env.INCLUDE};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\tr1;${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\${env.FLAVOR}", + "environment": "mingw_64" + } + ], + "name": "Mingw64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ + "mingw_64" + ], + "buildRoot": "${projectDir}\\build\\${name}", + "installRoot": "${projectDir}\\build\\${name}\\install", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "intelliSenseMode": "linux-gcc-x64", + "variables": [ + { + "name": "CMAKE_C_COMPILER", + "value": "${env.BIN_ROOT}\\gcc.exe" + }, + { + "name": "CMAKE_CXX_COMPILER", + "value": "${env.BIN_ROOT}\\g++.exe" + } + ] + } + ] +} \ No newline at end of file diff --git a/core/build.h b/core/build.h index a9a9777dd..4dc84a222 100755 --- a/core/build.h +++ b/core/build.h @@ -127,10 +127,18 @@ #define DC_PLATFORM_AURORA 6 /* Needs to be done, Uses newer 300 mhz sh4 + 150 mhz pvr mbx SoC */ + //HOST_OS #define OS_WINDOWS 0x10000001 #define OS_LINUX 0x10000002 #define OS_DARWIN 0x10000003 +#define OS_IOS 0x10000004 +#define OS_ANDROID 0x10000005 + +#define OS_UWP 0x10000011 +#define OS_NSW_HOS 0x80000001 +#define OS_PS4_BSD 0x80000002 + //HOST_CPU #define CPU_X86 0x20000001 @@ -138,11 +146,16 @@ #define CPU_MIPS 0x20000003 #define CPU_X64 0x20000004 #define CPU_GENERIC 0x20000005 //used for pnacl, emscripten, etc -#define CPU_ARM64 0x20000006 +#define CPU_PPC 0x20000006 +#define CPU_PPC64 0x20000007 +#define CPU_A64 0x20000008 +#define CPU_MIPS64 0x20000009 //BUILD_COMPILER -#define COMPILER_VC 0x30000001 -#define COMPILER_GCC 0x30000002 +#define COMPILER_VC 0x30000001 +#define COMPILER_GCC 0x30000002 +#define COMPILER_CLANG 0x30000002 +#define COMPILER_INTEL 0x30000002 //FEAT_SHREC, FEAT_AREC, FEAT_DSPREC #define DYNAREC_NONE 0x40000001 @@ -152,6 +165,8 @@ //automatic +#ifndef CMAKE_BUILD + #if defined(_WIN32) && !defined(TARGET_WIN86) && !defined(TARGET_WIN64) #if !defined(_M_AMD64) && !defined(__x86_64__) #define TARGET_WIN86 @@ -233,6 +248,8 @@ #define FEAT_DSPREC DYNAREC_NONE #endif +#endif // !CMAKE_BUILD + #if defined(TARGET_NO_NIXPROF) #define FEAT_HAS_NIXPROF 0 @@ -295,6 +312,19 @@ #error Dont use HOST_NO_AREC #endif + +// Compiler Related + +#if BUILD_COMPILER!=COMPILER_VC +#define ATTR_USED __attribute__((used)) +#define ATTR_UNUSED __attribute__((used)) +#else +#define ATTR_USED +#define ATTR_UNUSED +#endif + + + // TARGET PLATFORM #define RAM_SIZE_MAX (32*1024*1024) diff --git a/core/hw/modem/dns.cpp b/core/hw/modem/dns.cpp index 1dc7f46c8..1f1b3283e 100644 --- a/core/hw/modem/dns.cpp +++ b/core/hw/modem/dns.cpp @@ -18,6 +18,9 @@ You should have received a copy of the GNU General Public License along with reicast. If not, see . */ +#include "types.h" + +#if BUILD_COMPILER!=COMPILER_VC && (BUILD_COMPILER!=COMPILER_CLANG || !WIN32) #include #include @@ -145,3 +148,5 @@ char *read_name(char *reader, char *buffer, int *count) return name; } + +#endif // BUILD_COMPILER!=COMPILER_VC \ No newline at end of file diff --git a/core/hw/sh4/dyna/blockmanager.h b/core/hw/sh4/dyna/blockmanager.h index 5c11af77f..e21fb3dee 100644 --- a/core/hw/sh4/dyna/blockmanager.h +++ b/core/hw/sh4/dyna/blockmanager.h @@ -86,10 +86,7 @@ void bm_WriteBlockMap(const string& file); DynarecCodeEntryPtr DYNACALL bm_GetCode(u32 addr); extern "C" { -#ifndef _MSC_VER -__attribute__((used)) -#endif - DynarecCodeEntryPtr DYNACALL bm_GetCode2(u32 addr); +ATTR_USED DynarecCodeEntryPtr DYNACALL bm_GetCode2(u32 addr); } RuntimeBlockInfo* bm_GetBlock(void* dynarec_code); diff --git a/core/hw/sh4/sh4_interpreter.h b/core/hw/sh4/sh4_interpreter.h index 8d827af84..8a22caa83 100644 --- a/core/hw/sh4/sh4_interpreter.h +++ b/core/hw/sh4/sh4_interpreter.h @@ -61,9 +61,7 @@ void ExecuteDelayslot_RTE(); extern "C" { int UpdateSystem(); -#ifndef _MSC_VER -__attribute__((used)) -#endif - int UpdateSystem_INTC(); + +ATTR_USED int UpdateSystem_INTC(); } diff --git a/core/hw/sh4/sh4_sched.cpp b/core/hw/sh4/sh4_sched.cpp index baeef15a8..65b8af0c7 100755 --- a/core/hw/sh4/sh4_sched.cpp +++ b/core/hw/sh4/sh4_sched.cpp @@ -25,15 +25,15 @@ u64 sh4_sched_ffb; u32 sh4_sched_intr; -vector list; +vector sch_list; // using list as external inside a macro confuses clang and msc int sh4_sched_next_id=-1; u32 sh4_sched_remaining(int id, u32 reference) { - if (list[id].end != -1) + if (sch_list[id].end != -1) { - return list[id].end - reference; + return sch_list[id].end - reference; } else { @@ -51,7 +51,7 @@ void sh4_sched_ffts() u32 diff=-1; int slot=-1; - for (size_t i=0;i= 0 && cycles <= SH4_MAIN_CLOCK)); - list[id].start=sh4_sched_now(); + sch_list[id].start=sh4_sched_now(); if (cycles == -1) { - list[id].end = -1; + sch_list[id].end = -1; } else { - list[id].end = list[id].start + cycles; - if (list[id].end == -1) - list[id].end++; + sch_list[id].end = sch_list[id].start + cycles; + if (sch_list[id].end == -1) + sch_list[id].end++; } sh4_sched_ffts(); @@ -120,10 +120,10 @@ void sh4_sched_request(int id, int cycles) int sh4_sched_elapsed(int id) { - if (list[id].end!=-1) + if (sch_list[id].end!=-1) { - int rv=sh4_sched_now()-list[id].start; - list[id].start=sh4_sched_now(); + int rv=sh4_sched_now()-sch_list[id].start; + sch_list[id].start=sh4_sched_now(); return rv; } else @@ -132,12 +132,12 @@ int sh4_sched_elapsed(int id) void handle_cb(int id) { - int remain=list[id].end-list[id].start; + int remain=sch_list[id].end-sch_list[id].start; int elapsd=sh4_sched_elapsed(id); int jitter=elapsd-remain; - list[id].end=-1; - int re_sch=list[id].cb(list[id].tag,remain,jitter); + sch_list[id].end=-1; + int re_sch=sch_list[id].cb(sch_list[id].tag,remain,jitter); if (re_sch > 0) sh4_sched_request(id, max(0, re_sch - jitter)); @@ -156,7 +156,7 @@ void sh4_sched_tick(int cycles) sh4_sched_intr++; if (sh4_sched_next_id!=-1) { - for (int i=0;i= 0 || remaining == -1); diff --git a/core/rend/gl4/gltex.cpp b/core/rend/gl4/gltex.cpp index 85a0b9430..52aba888e 100644 --- a/core/rend/gl4/gltex.cpp +++ b/core/rend/gl4/gltex.cpp @@ -1,5 +1,5 @@ #include "gl4.h" -#include "glcache.h" +#include "../gles/glcache.h" GLuint gl4BindRTT(u32 addy, u32 fbw, u32 fbh, u32 channels, u32 fmt) { diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index e3fde42f4..a530f5b5c 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -39,7 +39,8 @@ #include "linux-dist/main.h" // FIXME for kcode[] #include "gui_util.h" #include "gui_android.h" -#include "version/version.h" + +#include "version.h" #include "oslib/audiostream.h" diff --git a/core/serialize.cpp b/core/serialize.cpp index f040744a4..9d28fd068 100644 --- a/core/serialize.cpp +++ b/core/serialize.cpp @@ -441,7 +441,7 @@ extern u32 old_dn; //./core/hw/sh4/sh4_sched.o extern u64 sh4_sched_ffb; extern u32 sh4_sched_intr; -extern vector list; +extern vector sch_list; //extern int sh4_sched_next_id; @@ -975,8 +975,6 @@ bool dc_serialize(void **data, unsigned int *total_size) REICAST_S(decoded_srimask); - - //default to nommu_full i = 3 ; if ( do_sqw_nommu == &do_sqw_nommu_area_3) @@ -1008,48 +1006,49 @@ bool dc_serialize(void **data, unsigned int *total_size) //extern vector list; - REICAST_S(list[aica_schid].tag) ; - REICAST_S(list[aica_schid].start) ; - REICAST_S(list[aica_schid].end) ; - REICAST_S(list[rtc_schid].tag) ; - REICAST_S(list[rtc_schid].start) ; - REICAST_S(list[rtc_schid].end) ; + REICAST_S(sch_list[aica_schid].tag) ; + REICAST_S(sch_list[aica_schid].start) ; + REICAST_S(sch_list[aica_schid].end) ; - REICAST_S(list[gdrom_schid].tag) ; - REICAST_S(list[gdrom_schid].start) ; - REICAST_S(list[gdrom_schid].end) ; + REICAST_S(sch_list[rtc_schid].tag) ; + REICAST_S(sch_list[rtc_schid].start) ; + REICAST_S(sch_list[rtc_schid].end) ; - REICAST_S(list[maple_schid].tag) ; - REICAST_S(list[maple_schid].start) ; - REICAST_S(list[maple_schid].end) ; + REICAST_S(sch_list[gdrom_schid].tag) ; + REICAST_S(sch_list[gdrom_schid].start) ; + REICAST_S(sch_list[gdrom_schid].end) ; - REICAST_S(list[dma_sched_id].tag) ; - REICAST_S(list[dma_sched_id].start) ; - REICAST_S(list[dma_sched_id].end) ; + REICAST_S(sch_list[maple_schid].tag) ; + REICAST_S(sch_list[maple_schid].start) ; + REICAST_S(sch_list[maple_schid].end) ; + + REICAST_S(sch_list[dma_sched_id].tag) ; + REICAST_S(sch_list[dma_sched_id].start) ; + REICAST_S(sch_list[dma_sched_id].end) ; for (int i = 0; i < 3; i++) { - REICAST_S(list[tmu_sched[i]].tag) ; - REICAST_S(list[tmu_sched[i]].start) ; - REICAST_S(list[tmu_sched[i]].end) ; + REICAST_S(sch_list[tmu_sched[i]].tag) ; + REICAST_S(sch_list[tmu_sched[i]].start) ; + REICAST_S(sch_list[tmu_sched[i]].end) ; } - REICAST_S(list[render_end_schid].tag) ; - REICAST_S(list[render_end_schid].start) ; - REICAST_S(list[render_end_schid].end) ; + REICAST_S(sch_list[render_end_schid].tag) ; + REICAST_S(sch_list[render_end_schid].start) ; + REICAST_S(sch_list[render_end_schid].end) ; - REICAST_S(list[vblank_schid].tag) ; - REICAST_S(list[vblank_schid].start) ; - REICAST_S(list[vblank_schid].end) ; + REICAST_S(sch_list[vblank_schid].tag) ; + REICAST_S(sch_list[vblank_schid].start) ; + REICAST_S(sch_list[vblank_schid].end) ; - REICAST_S(list[time_sync].tag) ; - REICAST_S(list[time_sync].start) ; - REICAST_S(list[time_sync].end) ; + REICAST_S(sch_list[time_sync].tag) ; + REICAST_S(sch_list[time_sync].start) ; + REICAST_S(sch_list[time_sync].end) ; - REICAST_S(list[modem_sched].tag) ; - REICAST_S(list[modem_sched].start) ; - REICAST_S(list[modem_sched].end) ; + REICAST_S(sch_list[modem_sched].tag) ; + REICAST_S(sch_list[modem_sched].start) ; + REICAST_S(sch_list[modem_sched].end) ; @@ -1408,50 +1407,50 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(sh4_sched_ffb); REICAST_US(sh4_sched_intr); - //extern vector list; + //extern vector sch_list; - REICAST_US(list[aica_schid].tag) ; - REICAST_US(list[aica_schid].start) ; - REICAST_US(list[aica_schid].end) ; + REICAST_US(sch_list[aica_schid].tag) ; + REICAST_US(sch_list[aica_schid].start) ; + REICAST_US(sch_list[aica_schid].end) ; - REICAST_US(list[rtc_schid].tag) ; - REICAST_US(list[rtc_schid].start) ; - REICAST_US(list[rtc_schid].end) ; + REICAST_US(sch_list[rtc_schid].tag) ; + REICAST_US(sch_list[rtc_schid].start) ; + REICAST_US(sch_list[rtc_schid].end) ; - REICAST_US(list[gdrom_schid].tag) ; - REICAST_US(list[gdrom_schid].start) ; - REICAST_US(list[gdrom_schid].end) ; + REICAST_US(sch_list[gdrom_schid].tag) ; + REICAST_US(sch_list[gdrom_schid].start) ; + REICAST_US(sch_list[gdrom_schid].end) ; - REICAST_US(list[maple_schid].tag) ; - REICAST_US(list[maple_schid].start) ; - REICAST_US(list[maple_schid].end) ; + REICAST_US(sch_list[maple_schid].tag) ; + REICAST_US(sch_list[maple_schid].start) ; + REICAST_US(sch_list[maple_schid].end) ; - REICAST_US(list[dma_sched_id].tag) ; - REICAST_US(list[dma_sched_id].start) ; - REICAST_US(list[dma_sched_id].end) ; + REICAST_US(sch_list[dma_sched_id].tag) ; + REICAST_US(sch_list[dma_sched_id].start) ; + REICAST_US(sch_list[dma_sched_id].end) ; for (int i = 0; i < 3; i++) { - REICAST_US(list[tmu_sched[i]].tag) ; - REICAST_US(list[tmu_sched[i]].start) ; - REICAST_US(list[tmu_sched[i]].end) ; + REICAST_US(sch_list[tmu_sched[i]].tag) ; + REICAST_US(sch_list[tmu_sched[i]].start) ; + REICAST_US(sch_list[tmu_sched[i]].end) ; } - REICAST_US(list[render_end_schid].tag) ; - REICAST_US(list[render_end_schid].start) ; - REICAST_US(list[render_end_schid].end) ; + REICAST_US(sch_list[render_end_schid].tag) ; + REICAST_US(sch_list[render_end_schid].start) ; + REICAST_US(sch_list[render_end_schid].end) ; - REICAST_US(list[vblank_schid].tag) ; - REICAST_US(list[vblank_schid].start) ; - REICAST_US(list[vblank_schid].end) ; + REICAST_US(sch_list[vblank_schid].tag) ; + REICAST_US(sch_list[vblank_schid].start) ; + REICAST_US(sch_list[vblank_schid].end) ; - REICAST_US(list[time_sync].tag) ; - REICAST_US(list[time_sync].start) ; - REICAST_US(list[time_sync].end) ; + REICAST_US(sch_list[time_sync].tag) ; + REICAST_US(sch_list[time_sync].start) ; + REICAST_US(sch_list[time_sync].end) ; - REICAST_US(list[modem_sched].tag) ; - REICAST_US(list[modem_sched].start) ; - REICAST_US(list[modem_sched].end) ; + REICAST_US(sch_list[modem_sched].tag) ; + REICAST_US(sch_list[modem_sched].start) ; + REICAST_US(sch_list[modem_sched].end) ; @@ -1800,48 +1799,48 @@ bool dc_unserialize(void **data, unsigned int *total_size) //extern vector list; - REICAST_US(list[aica_schid].tag) ; - REICAST_US(list[aica_schid].start) ; - REICAST_US(list[aica_schid].end) ; + REICAST_US(sch_list[aica_schid].tag) ; + REICAST_US(sch_list[aica_schid].start) ; + REICAST_US(sch_list[aica_schid].end) ; - REICAST_US(list[rtc_schid].tag) ; - REICAST_US(list[rtc_schid].start) ; - REICAST_US(list[rtc_schid].end) ; + REICAST_US(sch_list[rtc_schid].tag) ; + REICAST_US(sch_list[rtc_schid].start) ; + REICAST_US(sch_list[rtc_schid].end) ; - REICAST_US(list[gdrom_schid].tag) ; - REICAST_US(list[gdrom_schid].start) ; - REICAST_US(list[gdrom_schid].end) ; + REICAST_US(sch_list[gdrom_schid].tag) ; + REICAST_US(sch_list[gdrom_schid].start) ; + REICAST_US(sch_list[gdrom_schid].end) ; - REICAST_US(list[maple_schid].tag) ; - REICAST_US(list[maple_schid].start) ; - REICAST_US(list[maple_schid].end) ; + REICAST_US(sch_list[maple_schid].tag) ; + REICAST_US(sch_list[maple_schid].start) ; + REICAST_US(sch_list[maple_schid].end) ; - REICAST_US(list[dma_sched_id].tag) ; - REICAST_US(list[dma_sched_id].start) ; - REICAST_US(list[dma_sched_id].end) ; + REICAST_US(sch_list[dma_sched_id].tag) ; + REICAST_US(sch_list[dma_sched_id].start) ; + REICAST_US(sch_list[dma_sched_id].end) ; for (int i = 0; i < 3; i++) { - REICAST_US(list[tmu_sched[i]].tag) ; - REICAST_US(list[tmu_sched[i]].start) ; - REICAST_US(list[tmu_sched[i]].end) ; + REICAST_US(sch_list[tmu_sched[i]].tag) ; + REICAST_US(sch_list[tmu_sched[i]].start) ; + REICAST_US(sch_list[tmu_sched[i]].end) ; } - REICAST_US(list[render_end_schid].tag) ; - REICAST_US(list[render_end_schid].start) ; - REICAST_US(list[render_end_schid].end) ; + REICAST_US(sch_list[render_end_schid].tag) ; + REICAST_US(sch_list[render_end_schid].start) ; + REICAST_US(sch_list[render_end_schid].end) ; - REICAST_US(list[vblank_schid].tag) ; - REICAST_US(list[vblank_schid].start) ; - REICAST_US(list[vblank_schid].end) ; + REICAST_US(sch_list[vblank_schid].tag) ; + REICAST_US(sch_list[vblank_schid].start) ; + REICAST_US(sch_list[vblank_schid].end) ; - REICAST_US(list[time_sync].tag) ; - REICAST_US(list[time_sync].start) ; - REICAST_US(list[time_sync].end) ; + REICAST_US(sch_list[time_sync].tag) ; + REICAST_US(sch_list[time_sync].start) ; + REICAST_US(sch_list[time_sync].end) ; - REICAST_US(list[modem_sched].tag) ; - REICAST_US(list[modem_sched].start) ; - REICAST_US(list[modem_sched].end) ; + REICAST_US(sch_list[modem_sched].tag) ; + REICAST_US(sch_list[modem_sched].start) ; + REICAST_US(sch_list[modem_sched].end) ; diff --git a/core/stdclass.cpp b/core/stdclass.cpp index 59bf1e94a..f9acec72f 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -5,12 +5,10 @@ #include "types.h" #include "cfg/cfg.h" -#ifdef WIN32 -#include -#endif -#if BUILD_COMPILER==COMPILER_VC +#if BUILD_COMPILER==COMPILER_VC || (WIN32 && BUILD_COMPILER==COMPILER_CLANG) #include + #include #define access _access #define R_OK 4 #else diff --git a/core/types.h b/core/types.h index 4d9369127..4f3fb23b8 100644 --- a/core/types.h +++ b/core/types.h @@ -385,9 +385,9 @@ using namespace std; #include "stdclass.h" #ifndef RELEASE -#define EMUERROR(format, ...) printf("Error in %s:%s:%d: " format "\n", \ - strlen(__FILE__) <= 20 ? __FILE__ : __FILE__ + strlen(__FILE__) - 20, \ - __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define EMUERROR(format, ...) printf("Error in %20s:%s:%d: " format "\n", \ + __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__) +//strlen(__FILE__) <= 20 ? __FILE__ : __FILE__ + strlen(__FILE__) - 20, #else #define EMUERROR(format, ...) #endif @@ -521,7 +521,7 @@ typedef union #if COMPILER_VC==BUILD_COMPILER #pragma warning( disable : 4127 4996 /*4244*/) #else -#define stricmp strcasecmp +#define stricmp _stricmp // ISO , was strcasecmp #endif #ifndef STRIP_TEXT diff --git a/core/version.h.in b/core/version.h.in new file mode 100644 index 000000000..81a831a05 --- /dev/null +++ b/core/version.h.in @@ -0,0 +1,8 @@ +/* + * reicast: version.h + */ +#pragma once + +#define REICAST_VERSION "@GIT_VERSION@" +#define GIT_HASH "@GIT_HASH@" +#define BUILD_DATE __DATE__ \ No newline at end of file diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 3aa5a4a51..7e269a90d 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -673,7 +673,7 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine #ifdef _WIN64 AddVectoredExceptionHandler(1, ExeptionHandler); #else - SetUnhandledExceptionFilter(&ExeptionHandler); + SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)&ExeptionHandler); #endif #ifndef __GNUC__ __try diff --git a/shell/cmake/GetGitRevisionDescription.cmake b/shell/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 000000000..8ab03bc5f --- /dev/null +++ b/shell/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,168 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# git_local_changes() +# +# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. +# Uses the return code of "git diff-index --quiet HEAD --". +# Does not regard untracked files. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_local_changes _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + diff-index --quiet HEAD -- + WORKING_DIRECTORY + "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(res EQUAL 0) + set(${_var} "CLEAN" PARENT_SCOPE) + else() + set(${_var} "DIRTY" PARENT_SCOPE) + endif() +endfunction() diff --git a/shell/cmake/GetGitRevisionDescription.cmake.in b/shell/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 000000000..6d8b708ef --- /dev/null +++ b/shell/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,41 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/shell/cmake/android.cmake b/shell/cmake/android.cmake new file mode 100644 index 000000000..366fcb043 --- /dev/null +++ b/shell/cmake/android.cmake @@ -0,0 +1,101 @@ +## android.cmake +# + + + +function(TestPathNDK ndkPath) +# + file(TO_CMAKE_PATH "${ndkPath}" testPath) + + if(NOT NDK AND EXISTS "${testPath}") + if(EXISTS "${testPath}/ndk-bundle") + set(NDK ${testPath}/ndk-bundle PARENT_SCOPE) + elseif(EXISTS "${testPath}/sysroot") + set(NDK ${testPath} PARENT_SCOPE) + endif() + endif() +# +endfunction(TestPathNDK) + + +TestPathNDK("$ENV{ANDROID_HOME}") +TestPathNDK("$ENV{NDK}") +TestPathNDK("$ENV{NDK_ROOT}") + +if(NOT NDK) + message("Failed to find NDK !") +endif() + + + + + + +### option for ARM || ARM64 ? HOST isn't useful it's a cross ... + +#set(CMAKE_SYSTEM_PROCESSOR aarch64) + + + +set(CMAKE_SYSTEM_NAME Android) +set(CMAKE_SYSTEM_VERSION 22) # API level + +set(CMAKE_ANDROID_NDK ${NDK}) +set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a) #arm64-v8a , armeabi-v7a , armeabi +set(CMAKE_ANDROID_STL_TYPE c++_static) #gnustl_static libc++ will allow C++17, if you use _shared you must include in apk ! +set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang) + + +#arm $TOOLCHAIN/ arm-linux-androideabi /lib/ +#arm64 $TOOLCHAIN/ aarch64-linux-android /lib/ +#x86 $TOOLCHAIN/ i686-linux-android /lib/ +#x86_64 $TOOLCHAIN/ x86_64-linux-android /lib/ + + + +#include(${NDK}/build/cmake/android.toolchain.cmake) + + +set(ANDROID ON) + +add_definitions(-D_ANDROID -DANDROID) +add_definitions(-DANDROID_STL=c++_static) + + +add_definitions(-DTARGET_ANDROID) + +add_definitions(-DGLES) + + + + + +## FML + +#[[ +CMAKE_ANDROID_ANT_ADDITIONAL_OPTIONS +CMAKE_ANDROID_API +CMAKE_ANDROID_API_MIN +CMAKE_ANDROID_ARCH +CMAKE_ANDROID_ARCH_ABI +CMAKE_ANDROID_ARM_MODE +CMAKE_ANDROID_ARM_NEON +CMAKE_ANDROID_ASSETS_DIRECTORIES +CMAKE_ANDROID_GUI +CMAKE_ANDROID_JAR_DEPENDENCIES +CMAKE_ANDROID_JAR_DIRECTORIES +CMAKE_ANDROID_JAVA_SOURCE_DIR +CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES +CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES +CMAKE_ANDROID_NDK +CMAKE_ANDROID_NDK_DEPRECATED_HEADERS +CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG +CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION +CMAKE_ANDROID_PROCESS_MAX +CMAKE_ANDROID_PROGUARD +CMAKE_ANDROID_PROGUARD_CONFIG_PATH +CMAKE_ANDROID_SECURE_PROPS_PATH +CMAKE_ANDROID_SKIP_ANT_STEP +CMAKE_ANDROID_STANDALONE_TOOLCHAIN +CMAKE_ANDROID_STL_TYPE +#]] diff --git a/shell/cmake/config.cmake b/shell/cmake/config.cmake new file mode 100644 index 000000000..aa0c67d40 --- /dev/null +++ b/shell/cmake/config.cmake @@ -0,0 +1,481 @@ +## config module +# +# get luserx0 to doc this shit or something, vars in all caps are to be exported as defs if they aren't in build.h already +# handle options for FEAT per platform, so rec isn't built for targets w.o one... +# *TODO* fix Android for build system in emu too, OS_LINUX is hardly fitting: prob works better as PLATFORM_ANDROID_{S,N}DK or something +# *TODO* setup git version like it's done in VS/make and configure header so --version works still +# *TODO* lots of other shit to improve build, add enabling/disabling libs/features, setting 3rd party libs as either built in static, dynamic or shared/system +# +# + + +set(ZBUILD Off) + + + +set(BUILD_LIBS OFF) ## Scope:Local If set will build libs { dreamcast, osd, ... } +set(BUILD_LIB_TYPE STATIC) ## Scope:Local If BUILD_LIBS is set, will use this as type of lib to use { STATIC, SHARED, MODULE (plugin) } *TODO* +set(BUILD_SHARED_LIBS OFF) ## Scope:CMAKE If type is not specified in add_library, use SHARED + + + + +## Build flags ## +# + +set(DC_PLATFORM_MASK 7) # Z: Uh, not a bitset +set(DC_PLATFORM_DREAMCAST 0) # /* Works, for the most part */ +set(DC_PLATFORM_DEV_UNIT 1) # /* This is missing hardware */ +set(DC_PLATFORM_NAOMI 2) # /* Works, for the most part */ +set(DC_PLATFORM_NAOMI2 3) # /* Needs to be done, 2xsh4 + 2xpvr + custom TNL */ +set(DC_PLATFORM_ATOMISWAVE 4) # /* Needs to be done, DC-like hardware with possibly more ram */ +set(DC_PLATFORM_HIKARU 5) # /* Needs to be done, 2xsh4, 2x aica , custom vpu */ +set(DC_PLATFORM_AURORA 6) # /* Needs to be done, Uses newer 300 mhz sh4 + 150 mhz pvr mbx SoC */ + + + +set(OS_WINDOWS 0x10000001) # HOST_OS +set(OS_LINUX 0x10000002) +set(OS_DARWIN 0x10000003) +set(OS_IOS 0x10000004) # todo: iOS != OS_DARWIN +set(OS_ANDROID 0x10000005) # todo: should be SYSTEM_ANDROID but ! OS_LINUX + +set(OS_UWP 0x10000011) +set(OS_NSW_HOS 0x80000001) +set(OS_PS4_BSD 0x80000002) + + + +set(CPU_X86 0x20000001) # HOST_CPU +set(CPU_X64 0x20000004) +set(CPU_ARM 0x20000002) +set(CPU_A64 0x20000008) +set(CPU_MIPS 0x20000003) +set(CPU_MIPS64 0x20000009) +set(CPU_PPC 0x20000006) +set(CPU_PPC64 0x20000007) +set(CPU_GENERIC 0x20000005) # used for pnacl, emscripten, etc + +set(DYNAREC_NONE 0x40000001) # FEAT_SHREC, FEAT_AREC, FEAT_DSPREC +set(DYNAREC_JIT 0x40000002) +set(DYNAREC_CPP 0x40000003) + +set(COMPILER_VC 0x30000001) # BUILD_COMPILER +set(COMPILER_GCC 0x30000002) +set(COMPILER_CLANG 0x30000002) +set(COMPILER_INTEL 0x30000002) + + + + + + + +## These default to host, but are used for cross so make sure not to contaminate +# +# CMAKE_SYSTEM ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}. +# CMAKE_SYSTEM_NAME CMAKE_HOST_SYSTEM_NAME uname -s Linux, Windows, and Darwin +# CMAKE_SYSTEM_VERSION CMAKE_HOST_SYSTEM_VERSION uname -r +# CMAKE_SYSTEM_PROCESSOR CMAKE_HOST_SYSTEM_PROCESSOR uname -p +# +# +# +# BOOL: CMAKE_HOST_UNIX CMAKE_HOST_WIN32 CMAKE_HOST_APPLE +# +# +# CMAKE_LIBRARY_ARCHITECTURE CMAKE__LIBRARY_ARCHITECTURE /lib/ +# +# + + + + +## strings are used to append to path/file names, and to filter multiple possibilities down to one +# AMD64/x86_64:x64, i*86:x86, ppc/powerpc[64][b|l]e:ppc[64] etc +# +if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686") # todo: check MATCHES "i.86" ? + set(host_arch "x86") + set(HOST_CPU ${CPU_X86}) +# +elseif(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64") OR + ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")) + set(host_arch "x64") + set(HOST_CPU ${CPU_X64}) +# +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64") + set(host_arch "arm64") + set(HOST_CPU ${CPU_A64}) +# +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm") + set(host_arch "arm") + set(HOST_CPU ${CPU_ARM}) +# +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "ppc64") + set(host_arch "ppc64") + set(HOST_CPU ${CPU_PPC64}) +# +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "ppc") # has to be done after ppc64 obv + set(host_arch "ppc") + set(HOST_CPU ${CPU_PPC}) +# +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips64") # todo: check , r* names? + set(host_arch "mips64") + set(HOST_CPU ${CPU_MIPS64}) +# +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips") # todo: check , r* names? + set(host_arch "mips") + set(HOST_CPU ${CPU_MIPS}) +# +else() + message("Warning: Unknown Host System Processor: \"${CMAKE_SYSTEM_PROCESSOR}\"") + set(host_arch "${CMAKE_SYSTEM_PROCESSOR}") + set(HOST_CPU ${CPU_GENERIC}) +endif() + + + + +string(TOLOWER ${CMAKE_SYSTEM_NAME} host_os) + +#message(" - testing cmake host_os: \"${host_os}\"") + +## HOST_* is not TARGET_* ;; change ndc-e internal naming it's wrong , then change this ;; + +if("android" STREQUAL "${host_os}" OR ANDROID) + set(HOST_OS ${OS_LINUX}) # *FIXME* we might have to keep as OS_LINUX or add to full cleanup list :| + +elseif("windowsstore" STREQUAL "${host_os}") + set(HOST_OS ${OS_UWP}) + set(HOST_CPU ${CPU_X64}) + +elseif(CMAKE_HOST_WIN32) + set(HOST_OS ${OS_WINDOWS}) + +elseif(CMAKE_HOST_APPLE) + + if("${host_arch}" MATCHES "arm") + set(HOST_OS ${OS_IOS}) + set(TARGET_IOS On) + add_definitions(-DTARGET_IPHONE -DTARGET_IOS) + else() + set(HOST_OS ${OS_DARWIN}) # todo ios check, check compiler/arch? + set(TARGET_OSX On) + add_definitions(-DTARGET_OSX) + endif() + +elseif(CMAKE_HOST_UNIX) # GP UNIX MUST BE AFTER OTHER UNIX'ish options such as APPLE , it matches both + + set(HOST_OS ${OS_LINUX}) # todo android check, just check android vars? +endif() + + + +#option(TARGET_NO_REC BOOL "") +#option(TARGET_NO_AREC BOOL "") +#option(TARGET_NO_JIT BOOL "") + + + +## Dynarec avail on x86,x64,arm and aarch64 in arm.32 compat +# +if((${HOST_CPU} EQUAL ${CPU_X86}) OR (${HOST_CPU} EQUAL ${CPU_X64}) OR + (${HOST_CPU} EQUAL ${CPU_ARM}) OR (${HOST_CPU} EQUAL ${CPU_A64})) +# + message("Dynarec Features Available") + + set(FEAT_SHREC ${DYNAREC_JIT}) + set(FEAT_AREC ${DYNAREC_NONE}) + set(FEAT_DSPREC ${DYNAREC_NONE}) +# +else() + set(FEAT_SHREC ${DYNAREC_CPP}) + set(FEAT_AREC ${DYNAREC_NONE}) + set(FEAT_DSPREC ${DYNAREC_NONE}) +endif() + +## Handle TARGET_* to FEAT_ *FIXME* stupid use one or the other and propogate : part of build cleanup , TARGET_ will only be for platform specifics and FEAT_ as OPTIONS +# +if(TARGET_NO_REC) + set(FEAT_SHREC ${DYNAREC_NONE}) + set(FEAT_AREC ${DYNAREC_NONE}) + set(FEAT_DSPREC ${DYNAREC_NONE}) +endif() + +if(TARGET_NO_AREC) + set(FEAT_SHREC ${DYNAREC_JIT}) + set(FEAT_AREC ${DYNAREC_NONE}) + set(FEAT_DSPREC ${DYNAREC_NONE}) +endif() + +if(TARGET_NO_JIT) + set(FEAT_SHREC ${DYNAREC_CPP}) + set(FEAT_AREC ${DYNAREC_NONE}) + set(FEAT_DSPREC ${DYNAREC_NONE}) +endif() + + + + + +######## Looks like something to delete, but if we're going to handle options here and NOT in libosd/lib* ######### + +# FindNativeCompilers() +## options BUILD_COMPILER { GCC, Clang, Intel, RealView? } + + +#set(CMAKE_C_COMPILER clang) +#set(CMAKE_C_COMPILER_TARGET ${triple}) +#set(CMAKE_CXX_COMPILER clang++) +#set(CMAKE_CXX_COMPILER_TARGET ${triple}) + + + +if(${HOST_OS} EQUAL ${OS_LINUX}) +# option SUPPORT_X11 +# option FEAT_HAS_NIXPROF +# option EMSCripten +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") +# + set(BUILD_COMPILER ${COMPILER_VC}) + message("MSVC Platform: ${CMAKE_VS_PLATFORM_NAME}") + message("MSVC Toolset: ${CMAKE_VS_PLATFORM_TOOLSET}") + + + add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1) + + if("${HOST_OS}" STREQUAL "${OS_UWP}") + set(_CXX_FLAGS "/ZW ") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /AppContainer") + endif() +# +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(BUILD_COMPILER ${COMPILER_GCC}) +# +elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AppleClang ffs + set(BUILD_COMPILER ${COMPILER_CLANG}) +# +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + set(BUILD_COMPILER ${COMPILER_INTEL}) +# +else() + message("Unknown Compiler: ${CMAKE_CXX_COMPILER_ID}") +endif() + + + + +## Setup some common flags +# +if ((${BUILD_COMPILER} EQUAL ${COMPILER_VC}) OR + (${BUILD_COMPILER} EQUAL ${COMPILER_CLANG} AND ${HOST_OS} EQUAL ${OS_WINDOWS})) + + if((${HOST_CPU} EQUAL ${CPU_X64}) AND (${FEAT_SHREC} EQUAL ${DYNAREC_JIT})) # AND NOT "${NINJA}" STREQUAL "") + set(FEAT_SHREC ${DYNAREC_CPP}) + message("---x64 rec disabled for VC x64 via NINJA") + endif() + + add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1) + +if(${BUILD_COMPILER} EQUAL ${COMPILER_CLANG}) + add_definitions(/DXBYAK_NO_OP_NAMES /DTARGET_NO_OPENMP) #*FIXME* check openmp on clang-cl + remove_definitions(/U_HAS_STD_BYTE) + set(_CXX_FLAGS "/std:c++14") # /U_HAS_STD_BYTE not working, have to use c++14 not 17 :| + set(_C_FLAGS "-Wno-unused-function -Wno-unused-variable") +endif() + + +elseif ((${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) OR + (${BUILD_COMPILER} EQUAL ${COMPILER_CLANG})) # AND NOT ${HOST_OS} EQUAL ${OS_WINDOWS})) + + + set(_C_FLAGS "-fno-operator-names") # or add_definitions(/DXBYAK_NO_OP_NAMES) + + + if(USE_32B OR TARGET_LINUX_X86) + set(_C_FLAGS "${_C_FLAGS} -m32") + endif() + + if((${HOST_CPU} EQUAL ${CPU_X86}) OR (${HOST_CPU} EQUAL ${CPU_X64})) + set(_C_FLAGS "${_C_FLAGS} -msse4") + + if(NOT CMAKE_HOST_APPLE) + set(_C_FLAGS "${_C_FLAGS} -fopenmp") + endif() + endif() # X86 family + + + set(_CXX_FLAGS "${_CXX_FLAGS} -std=c++17 -fcxx-exceptions") ## xbyak needs exceptions + + +endif() + + +set(_CXX_FLAGS "${_CXX_FLAGS} ${_C_FLAGS}") + + + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_C_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_CXX_FLAGS}") + + + +#if defined(TARGET_NAOMI) + #define DC_PLATFORM DC_PLATFORM_NAOMI + #undef TARGET_NAOMI +#endif + + + +#if defined(TARGET_NO_NIXPROF) +#define FEAT_HAS_NIXPROF 0 +#endif + +#if defined(TARGET_NO_COREIO_HTTP) +#define FEAT_HAS_COREIO_HTTP 0 +#endif + +#if defined(TARGET_SOFTREND) # need -fopenmp + #define FEAT_HAS_SOFTREND 1 +#endif + + +if (TARGET_NSW) # -DCMAKE_TOOLCHAIN_FILE=./cmake/devkitA64.cmake -DTARGET_NSW=ON + set(HOST_OS ${OS_NSW_HOS}) + + message(" DEVKITA64: ${DEVKITA64} ") + message("HOST_OS ${HOST_OS}") + + add_definitions(-D__SWITCH__ -DGLES -DMESA_EGL_NO_X11_HEADERS) + add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_EXCEPTIONS -DTARGET_NO_NIXPROF) + add_definitions(-DTARGET_NO_COREIO_HTTP -DTARGET_NO_WEBUI -UTARGET_SOFTREND) + add_definitions(-D_GLIBCXX_USE_C99_MATH_TR1 -D_LDBL_EQ_DBL) + +endif() + +if (TARGET_PS4) # -DCMAKE_TOOLCHAIN_FILE=./cmake/{ps4sdk,clang_scei}.cmake -DTARGET_PS4=ON + set(HOST_OS ${OS_PS4_BSD}) + message("HOST_OS ${HOST_OS}") + + + add_definitions(-DPS4 -DTARGET_PS4 -DTARGET_BSD -D__ORBIS__ -DGLES -DMESA_EGL_NO_X11_HEADERS) ## last needed for __unix__ on eglplatform.h + add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_EXCEPTIONS -DTARGET_NO_NIXPROF) + add_definitions(-DTARGET_NO_COREIO_HTTP -DTARGET_NO_WEBUI -UTARGET_SOFTREND) + + + message("*******FIXME******** LARGE PAGES !!") +endif() + + + +if(ZBUILD) + set(DEBUG_CMAKE ON) + add_definitions(-D_Z_) # Get rid of some warnings and internal dev testing + + if(NOT TARGET_PS4 AND NOT TARGET_NSW AND + NOT TARGET_OSX AND NOT TARGET_IOS ) + set(USE_QT ON) + endif() +endif() + + + +# configure options for osd/ui +# osd_default, osd_qt +# ui_default, ui_sdl, ui_qt +# USE_NATIVE , USE_SDL , USE_QT -- these (can) define multiple + +option(USE_QT False "Use Qt5 for UI and support OS Deps.") + + + + +#option TARGET_NO_WEBUI + + + + + +#option(BUILD_TESTS "Build tests" OFF) # todo: luserx0 this is your arena, you want tests add em + + +add_definitions(-DCMAKE_BUILD) + + + + +add_definitions(-DHOST_OS=${HOST_OS}) +add_definitions(-DHOST_CPU=${HOST_CPU}) + +add_definitions(-DFEAT_AREC=${FEAT_AREC}) +add_definitions(-DFEAT_SHREC=${FEAT_SHREC}) +add_definitions(-DFEAT_DSPREC=${FEAT_DSPREC}) + +add_definitions(-DBUILD_COMPILER=${BUILD_COMPILER}) + +add_definitions(-DTARGET_NO_WEBUI) +add_definitions(-DDEF_CONSOLE) + + +set(RE_CMAKE_CONFIGURED 1) +#add_definitions(-D=${}) + + + + + + + + + + + + + + +### These were for internal testing, don't use ### +# +function(CpuIs CpuType Res) + set(${Res} OFF PARENT_SCOPE) + if (${HOST_CPU} EQUAL ${CpuType}) + set(${Res} ON PARENT_SCOPE) + endif() +endfunction() + +macro(CpuIsX86 res) + CpuIs(CPU_X86 ${res}) +endmacro() + +macro(CpuIsX64 res) + CpuIs(CPU_X64 ${res}) +endmacro() + +macro(CpuIsARM res) + CpuIs(CPU_ARM ${res}) +endmacro() + +macro(CpuIsA64 res) + CpuIs(CPU_A64 ${res}) +endmacro() + +macro(CpuIsPPC res) + CpuIs(CPU_PPC ${res}) +endmacro() + +macro(CpuIsPPC64 res) + CpuIs(CPU_PPC64 ${res}) +endmacro() + +macro(CpuIsMIPS res) + CpuIs(CPU_MIPS ${res}) +endmacro() + +macro(CpuIsMIPS64 res) + CpuIs(CPU_MIPS64 ${res}) +endmacro() + + + + + diff --git a/shell/cmake/devkitA64.cmake b/shell/cmake/devkitA64.cmake new file mode 100644 index 000000000..3eb80ff24 --- /dev/null +++ b/shell/cmake/devkitA64.cmake @@ -0,0 +1,41 @@ +## devkitA64.cmake - devkitpro A64 cross-compile +# +set(CMAKE_SYSTEM_NAME Linux) # this one is important // Add Platform/switch to use this name ... +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_SYSTEM_VERSION 1) # this one not so much + + +set(DEVKITPRO $ENV{DEVKITPRO}) +set(DEVKITA64 $ENV{DEVKITA64}) + + +if ("" STREQUAL "${DEVKITPRO}") + set(DEVKITA64 "/opt/devkitpro") +endif() + +if ("" STREQUAL "${DEVKITA64}") + set(DEVKITA64 ${DEVKITPRO}/devkitA64) +endif() + + +## specify the cross compiler +# +set(CMAKE_C_COMPILER ${DEVKITA64}/bin/aarch64-none-elf-gcc) +set(CMAKE_CXX_COMPILER ${DEVKITA64}/bin/aarch64-none-elf-g++) + + +set(CMAKE_FIND_ROOT_PATH ${DEVKITA64}) # where is the target environment + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + + + + +include_directories(${DEVKITPRO}/libnx/include) + + + +set(TARGET_NSW ON) diff --git a/shell/cmake/ps4sdk.cmake b/shell/cmake/ps4sdk.cmake new file mode 100644 index 000000000..d8cac168f --- /dev/null +++ b/shell/cmake/ps4sdk.cmake @@ -0,0 +1,130 @@ +## ps4sdk.cmake - devkitpro A64 cross-compile +# +set(CMAKE_SYSTEM_NAME FreeBSD) # this one is important +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(CMAKE_SYSTEM_VERSION 9) # this one not so much + + + + +set(TARGET_PS4 ON) +set(TARGET_BSD ON) + + + +### This shit is very WIP ### +# +## TODO: Check for + + +set(PS4SDK $ENV{PS4SDK}) +set(SCESDK $ENV{SCESDK}) + +set(USE_SCE ON) +set(PS4_PKG ON) + +if(PS4_PKG) + add_definitions(-DPS4_PKG) +endif() + + + +if ("" STREQUAL "${PS4SDK}") + if ("Windows" STREQUAL "${CMAKE_HOST_SYSTEM_NAME}") + set(PS4SDK "C:/Dev/SDK/PS4") + else() + set(PS4SDK "/opt/ps4") + endif() +endif() + + + +set(TAUON_SDK ${PS4SDK}/tauon) + + + +if(USE_SCE) +# + set(PS4SDK ${PS4SDK}/SCE/PS4SDK) + + set(PS4HOST ${PS4SDK}/host_tools) + set(PS4TARGET ${PS4SDK}/target) + + set(toolPrefix "orbis-") + set(toolSuffix ".exe") + + set(CMAKE_C_COMPILER ${PS4HOST}/bin/${toolPrefix}clang${toolSuffix}) + set(CMAKE_CXX_COMPILER ${PS4HOST}/bin/${toolPrefix}clang++${toolSuffix}) + + set(CMAKE_FIND_ROOT_PATH ${PS4TARGET}) # where is the target environment + + + + set (PS4_inc_dirs + ${TAUON_SDK}/include + ${PS4TARGET}/include + ${PS4TARGET}/include_common + ) + +# set (PS4_link_dirs +# "${PS4TARGET}/lib" +# "${PS4TARGET}/tauon/lib" +# ) + + +#LDFLAGS += -L $(TAUON_SDK_DIR)/lib -L $(SCE_ORBIS_SDK_DIR)/target/lib + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--addressing=non-aslr,--strip-unused-data ") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L ${TAUON_SDK}/lib -L ${PS4TARGET}/lib") + + message("CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}") +# +else() +# + set(triple "x86_64-scei-ps4") + + set(CMAKE_C_COMPILER_TARGET ${triple}) + set(CMAKE_CXX_COMPILER_TARGET ${triple}) + + set(CMAKE_C_COMPILER clang) + set(CMAKE_CXX_COMPILER clang++) + + + set (PS4_inc_dirs + ${TAUON_SDK}/include + + ${PS4SDK}/include + ${PS4SDK}/tauon/include + ) + +# set (PS4_link_dirs +# "${PS4SDK}/lib" +# "${PS4SDK}/tauon/lib" +# ) + + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--addressing=non-aslr,--strip-unused-data -L${TAUON_SDK}/lib") +# +endif() + + + + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) # for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + + +include_directories(${PS4_inc_dirs}) + + + + + ### Add a helper to add libSce PREFIX and [_tau]*_stub[_weak]*.a SUFFIX + # +link_libraries( + kernel_tau_stub_weak SceSysmodule_tau_stub_weak SceSystemService_stub_weak SceSystemService_tau_stub_weak SceShellCoreUtil_tau_stub_weak ScePigletv2VSH_tau_stub_weak kernel_util + ScePad_stub_weak SceNet_stub_weak SceCommonDialog_stub_weak ScePosix_stub_weak +) + + + diff --git a/shell/reicast.vcxproj b/shell/reicast.vcxproj index 2f10bff9e..3d10f789a 100644 --- a/shell/reicast.vcxproj +++ b/shell/reicast.vcxproj @@ -574,7 +574,7 @@ Win32Proj reicast reicast - 10.0.17134.0 + 10.0.17763.0 From b6c234b71b1586e66f9c14f26e94d16f80f2a999 Mon Sep 17 00:00:00 2001 From: david miller Date: Fri, 12 Apr 2019 17:19:40 -0400 Subject: [PATCH 36/73] revert to using strcasecmp for other platforms --- CMakeSettings.json | 4 ++++ core/types.h | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index 8ddfb307d..4e5b0d73c 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -86,6 +86,8 @@ } ] }, + + // Console SDK's { "name": "PS4 SDK", "generator": "Ninja", @@ -114,6 +116,8 @@ "buildCommandArgs": "-v", "ctestCommandArgs": "" }, + + // UWP and VS Gen (temp?) { "name": "uwp-x64-Release", "generator": "Visual Studio 15 2017 Win64", diff --git a/core/types.h b/core/types.h index 4f3fb23b8..fbcb74c7c 100644 --- a/core/types.h +++ b/core/types.h @@ -518,10 +518,10 @@ typedef union -#if COMPILER_VC==BUILD_COMPILER +#if BUILD_COMPILER==COMPILER_VC || BUILD_COMPILER==COMPILER_CLANG && WIN32 #pragma warning( disable : 4127 4996 /*4244*/) #else -#define stricmp _stricmp // ISO , was strcasecmp +#define stricmp strcasecmp #endif #ifndef STRIP_TEXT From 68ee192ad4bb3c178e6200490cfc3235fa7b8e1c Mon Sep 17 00:00:00 2001 From: david miller Date: Fri, 12 Apr 2019 18:08:36 -0400 Subject: [PATCH 37/73] compiler def. fixes --- core/build.h | 4 ++-- shell/cmake/config.cmake | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/build.h b/core/build.h index 4dc84a222..800e5a1e4 100755 --- a/core/build.h +++ b/core/build.h @@ -154,8 +154,8 @@ //BUILD_COMPILER #define COMPILER_VC 0x30000001 #define COMPILER_GCC 0x30000002 -#define COMPILER_CLANG 0x30000002 -#define COMPILER_INTEL 0x30000002 +#define COMPILER_CLANG 0x30000003 +#define COMPILER_INTEL 0x30000004 //FEAT_SHREC, FEAT_AREC, FEAT_DSPREC #define DYNAREC_NONE 0x40000001 diff --git a/shell/cmake/config.cmake b/shell/cmake/config.cmake index aa0c67d40..ad4b53b9d 100644 --- a/shell/cmake/config.cmake +++ b/shell/cmake/config.cmake @@ -62,8 +62,8 @@ set(DYNAREC_CPP 0x40000003) set(COMPILER_VC 0x30000001) # BUILD_COMPILER set(COMPILER_GCC 0x30000002) -set(COMPILER_CLANG 0x30000002) -set(COMPILER_INTEL 0x30000002) +set(COMPILER_CLANG 0x30000003) +set(COMPILER_INTEL 0x30000004) @@ -265,11 +265,10 @@ endif() - ## Setup some common flags # if ((${BUILD_COMPILER} EQUAL ${COMPILER_VC}) OR - (${BUILD_COMPILER} EQUAL ${COMPILER_CLANG} AND ${HOST_OS} EQUAL ${OS_WINDOWS})) + (${BUILD_COMPILER} EQUAL ${COMPILER_CLANG}) AND (${HOST_OS} STREQUAL ${OS_WINDOWS})) if((${HOST_CPU} EQUAL ${CPU_X64}) AND (${FEAT_SHREC} EQUAL ${DYNAREC_JIT})) # AND NOT "${NINJA}" STREQUAL "") set(FEAT_SHREC ${DYNAREC_CPP}) @@ -278,12 +277,12 @@ if ((${BUILD_COMPILER} EQUAL ${COMPILER_VC}) OR add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1) -if(${BUILD_COMPILER} EQUAL ${COMPILER_CLANG}) - add_definitions(/DXBYAK_NO_OP_NAMES /DTARGET_NO_OPENMP) #*FIXME* check openmp on clang-cl - remove_definitions(/U_HAS_STD_BYTE) - set(_CXX_FLAGS "/std:c++14") # /U_HAS_STD_BYTE not working, have to use c++14 not 17 :| - set(_C_FLAGS "-Wno-unused-function -Wno-unused-variable") -endif() + if(${BUILD_COMPILER} EQUAL ${COMPILER_CLANG}) + add_definitions(/DXBYAK_NO_OP_NAMES /DTARGET_NO_OPENMP) #*FIXME* check openmp on clang-cl + remove_definitions(/U_HAS_STD_BYTE) + set(_CXX_FLAGS "/std:c++14") # /U_HAS_STD_BYTE not working, have to use c++14 not 17 :| + set(_C_FLAGS "-Wno-unused-function -Wno-unused-variable") + endif() elseif ((${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) OR @@ -316,8 +315,8 @@ set(_CXX_FLAGS "${_CXX_FLAGS} ${_C_FLAGS}") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_C_FLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_CXX_FLAGS}") +set(CMAKE_C_FLAGS " ${_C_FLAGS}") # ${CMAKE_C_FLAGS} -- these hold default VC flags for non VC Build ? +set(CMAKE_CXX_FLAGS " ${_CXX_FLAGS}") # ${CMAKE_CXX_FLAGS} From 803cad95f97bccad675db8d32e2a8951f7dae69a Mon Sep 17 00:00:00 2001 From: david miller Date: Fri, 12 Apr 2019 18:13:09 -0400 Subject: [PATCH 38/73] gcc flags & misc --- core/hw/modem/dns.cpp | 2 +- core/stdclass.cpp | 2 +- core/types.h | 2 +- shell/cmake/config.cmake | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/hw/modem/dns.cpp b/core/hw/modem/dns.cpp index 1f1b3283e..5eaaf9c8e 100644 --- a/core/hw/modem/dns.cpp +++ b/core/hw/modem/dns.cpp @@ -20,7 +20,7 @@ */ #include "types.h" -#if BUILD_COMPILER!=COMPILER_VC && (BUILD_COMPILER!=COMPILER_CLANG || !WIN32) +#if BUILD_COMPILER!=COMPILER_VC && (BUILD_COMPILER!=COMPILER_CLANG || !defined(WIN32)) #include #include diff --git a/core/stdclass.cpp b/core/stdclass.cpp index f9acec72f..0ac32fb1d 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -6,7 +6,7 @@ #include "cfg/cfg.h" -#if BUILD_COMPILER==COMPILER_VC || (WIN32 && BUILD_COMPILER==COMPILER_CLANG) +#if BUILD_COMPILER==COMPILER_VC || BUILD_COMPILER==COMPILER_CLANG && defined(WIN32) #include #include #define access _access diff --git a/core/types.h b/core/types.h index fbcb74c7c..ac087590e 100644 --- a/core/types.h +++ b/core/types.h @@ -518,7 +518,7 @@ typedef union -#if BUILD_COMPILER==COMPILER_VC || BUILD_COMPILER==COMPILER_CLANG && WIN32 +#if BUILD_COMPILER==COMPILER_VC || BUILD_COMPILER==COMPILER_CLANG && defined(WIN32) #pragma warning( disable : 4127 4996 /*4244*/) #else #define stricmp strcasecmp diff --git a/shell/cmake/config.cmake b/shell/cmake/config.cmake index ad4b53b9d..ac4eb3238 100644 --- a/shell/cmake/config.cmake +++ b/shell/cmake/config.cmake @@ -305,7 +305,7 @@ elseif ((${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) OR endif() # X86 family - set(_CXX_FLAGS "${_CXX_FLAGS} -std=c++17 -fcxx-exceptions") ## xbyak needs exceptions + set(_CXX_FLAGS "${_CXX_FLAGS} -std=c++17") # -fcxx-exceptions") ## xbyak needs exceptions endif() From 6539b8c247d867bb0c4ba4480705d21a13c3729f Mon Sep 17 00:00:00 2001 From: david miller Date: Fri, 12 Apr 2019 18:24:11 -0400 Subject: [PATCH 39/73] _mkdir guard --- core/stdclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/stdclass.cpp b/core/stdclass.cpp index 0ac32fb1d..006255100 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -142,7 +142,7 @@ string get_game_dir() bool make_directory(const string& path) { -#ifdef WIN32 +#ifdef BUILD_COMPILER==COMPILER_VC || (BUILD_COMPILER==COMPILER_CLANG && defined(WIN32)) return _mkdir(path.c_str()) == 0; #else return mkdir(path.c_str(), 0755) == 0; From 3157520deeb6d47cdafa2e454a4f45ac3e265472 Mon Sep 17 00:00:00 2001 From: david miller Date: Fri, 12 Apr 2019 19:15:31 -0400 Subject: [PATCH 40/73] mingw64 fixes --- CMakeSettings.json | 4 ++-- core/build.h | 2 ++ core/hw/modem/dns.cpp | 2 +- core/stdclass.cpp | 10 +++++++--- core/types.h | 2 +- shell/cmake/config.cmake | 4 ++-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index 4e5b0d73c..7fbe9b101 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -149,7 +149,7 @@ { "environments": [ { - "MINGW64_ROOT": "C:\\msys64\\mingw64", + //"MINGW64_ROOT": "C:\\msys64\\mingw64", "BIN_ROOT": "${env.MINGW64_ROOT}\\bin", "FLAVOR": "x86_64-w64-mingw32", "TOOLSET_VERSION": "7.3.0", @@ -184,7 +184,7 @@ { "environments": [ { - "MINGW64_ROOT": "C:\\msys64\\mingw64", + //"MINGW64_ROOT": "C:\\msys64\\mingw64", "BIN_ROOT": "${env.MINGW64_ROOT}\\bin", "FLAVOR": "x86_64-w64-mingw32", "TOOLSET_VERSION": "7.3.0", diff --git a/core/build.h b/core/build.h index 800e5a1e4..57a00a46c 100755 --- a/core/build.h +++ b/core/build.h @@ -315,6 +315,8 @@ // Compiler Related +#define COMPILER_VC_OR_CLANG_WIN32 ((BUILD_COMPILER == COMPILER_VC) || (BUILD_COMPILER == COMPILER_CLANG) && defined(WIN32)) + #if BUILD_COMPILER!=COMPILER_VC #define ATTR_USED __attribute__((used)) #define ATTR_UNUSED __attribute__((used)) diff --git a/core/hw/modem/dns.cpp b/core/hw/modem/dns.cpp index 5eaaf9c8e..95c8657c4 100644 --- a/core/hw/modem/dns.cpp +++ b/core/hw/modem/dns.cpp @@ -149,4 +149,4 @@ char *read_name(char *reader, char *buffer, int *count) return name; } -#endif // BUILD_COMPILER!=COMPILER_VC \ No newline at end of file +#endif // !COMPILER_VC_OR_CLANG_WIN32 \ No newline at end of file diff --git a/core/stdclass.cpp b/core/stdclass.cpp index 006255100..ca773ee24 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -6,7 +6,7 @@ #include "cfg/cfg.h" -#if BUILD_COMPILER==COMPILER_VC || BUILD_COMPILER==COMPILER_CLANG && defined(WIN32) +#if COMPILER_VC_OR_CLANG_WIN32 #include #include #define access _access @@ -142,8 +142,12 @@ string get_game_dir() bool make_directory(const string& path) { -#ifdef BUILD_COMPILER==COMPILER_VC || (BUILD_COMPILER==COMPILER_CLANG && defined(WIN32)) - return _mkdir(path.c_str()) == 0; +#if COMPILER_VC_OR_CLANG_WIN32 +#define mkdir _mkdir +#endif + +#ifdef _WIN32 + return mkdir(path.c_str()) == 0; #else return mkdir(path.c_str(), 0755) == 0; #endif diff --git a/core/types.h b/core/types.h index ac087590e..771d758e6 100644 --- a/core/types.h +++ b/core/types.h @@ -518,7 +518,7 @@ typedef union -#if BUILD_COMPILER==COMPILER_VC || BUILD_COMPILER==COMPILER_CLANG && defined(WIN32) +#if COMPILER_VC_OR_CLANG_WIN32 #pragma warning( disable : 4127 4996 /*4244*/) #else #define stricmp strcasecmp diff --git a/shell/cmake/config.cmake b/shell/cmake/config.cmake index ac4eb3238..1abf2258a 100644 --- a/shell/cmake/config.cmake +++ b/shell/cmake/config.cmake @@ -289,7 +289,7 @@ elseif ((${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) OR (${BUILD_COMPILER} EQUAL ${COMPILER_CLANG})) # AND NOT ${HOST_OS} EQUAL ${OS_WINDOWS})) - set(_C_FLAGS "-fno-operator-names") # or add_definitions(/DXBYAK_NO_OP_NAMES) + set(_C_FLAGS "-fno-operator-names -fpermissive") # or add_definitions(/DXBYAK_NO_OP_NAMES) if(USE_32B OR TARGET_LINUX_X86) @@ -305,7 +305,7 @@ elseif ((${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) OR endif() # X86 family - set(_CXX_FLAGS "${_CXX_FLAGS} -std=c++17") # -fcxx-exceptions") ## xbyak needs exceptions + set(_CXX_FLAGS "${_CXX_FLAGS} -std=c++11") # -fcxx-exceptions") ## xbyak needs exceptions endif() From a1df35d13d0f2c288bb7b23960eb4ae7166dead2 Mon Sep 17 00:00:00 2001 From: david miller Date: Fri, 12 Apr 2019 19:42:14 -0400 Subject: [PATCH 41/73] cmake cleanup --- CMakeLists.txt | 38 ++++++++++++------------- shell/cmake/config.cmake | 60 +--------------------------------------- 2 files changed, 19 insertions(+), 79 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49a9a1138..9a757f3d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,24 +12,10 @@ set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) -## built-in cmake modules # -# -#include(CheckIncludeFiles) -#include(CheckFunctionExists) -#include(CheckCSourceCompiles) - -#set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin) -#set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) -#set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) - - - set(reicast_root_path "${CMAKE_CURRENT_SOURCE_DIR}") set(reicast_core_path "${reicast_root_path}/core") set(reicast_shell_path "${reicast_root_path}/shell") -include_directories ("${reicast_core_path}") - list(APPEND CMAKE_MODULE_PATH "${reicast_shell_path}/cmake") @@ -77,7 +63,6 @@ set(core_SRCS ${reios_SRCS} ${imgread_SRCS} ${profiler_SRCS} -# ${archive_SRCS} ${d_core}/archive/archive.cpp ${d_core}/archive/archive.h ${d_core}/nullDC.cpp ${d_core}/stdclass.cpp @@ -85,6 +70,10 @@ set(core_SRCS ${d_core}/serialize.cpp ) + +if(${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) # Add Clang if NOT WIN32 *FIXME* + list(APPEND core_SRCS ${archive_SRCS}) +endif() if(${FEAT_SHREC} EQUAL ${DYNAREC_JIT}) # @@ -149,9 +138,6 @@ set(pico_SRCS ${picoModS} ${picoStkS}) set(deps_SRCS ${lz_SRCS} -# ${lzip_SRCS} -# ${lzma_SRCS} -# ${pico_SRCS} ${lpng_SRCS} ${lelf_SRCS} ${chdr_SRCS} @@ -166,7 +152,13 @@ set(deps_SRCS ${xbyak_H} ) - +if(${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) # Add Clang if NOT WIN32 *FIXME* + list(APPEND deps_SRCS + ${lzip_SRCS} + ${lzma_SRCS} + ${pico_SRCS} + ) +endif() ### libosd.cmake ################################################################################ @@ -187,7 +179,7 @@ if (${HOST_OS} EQUAL ${OS_WINDOWS}) list(APPEND osd_SRCS ${d_aout}/audiobackend_directsound.cpp) - link_libraries(Dsound.lib winmm.lib) + link_libraries(dsound.lib winmm.lib xinput.lib wsock32.lib opengl32.lib) elseif (${HOST_OS} EQUAL ${OS_LINUX} OR ${HOST_OS} EQUAL ${OS_ANDROID}) @@ -247,6 +239,12 @@ endif() +## + +include_directories ("${reicast_core_path}") + +add_definitions(-D_7ZIP_ST -DCHD5_LZMA) + set(reicast_SRCS ${core_SRCS} ${deps_SRCS} ${osd_SRCS}) diff --git a/shell/cmake/config.cmake b/shell/cmake/config.cmake index 1abf2258a..d1dfd59e4 100644 --- a/shell/cmake/config.cmake +++ b/shell/cmake/config.cmake @@ -287,10 +287,6 @@ if ((${BUILD_COMPILER} EQUAL ${COMPILER_VC}) OR elseif ((${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) OR (${BUILD_COMPILER} EQUAL ${COMPILER_CLANG})) # AND NOT ${HOST_OS} EQUAL ${OS_WINDOWS})) - - - set(_C_FLAGS "-fno-operator-names -fpermissive") # or add_definitions(/DXBYAK_NO_OP_NAMES) - if(USE_32B OR TARGET_LINUX_X86) set(_C_FLAGS "${_C_FLAGS} -m32") @@ -305,7 +301,7 @@ elseif ((${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) OR endif() # X86 family - set(_CXX_FLAGS "${_CXX_FLAGS} -std=c++11") # -fcxx-exceptions") ## xbyak needs exceptions + set(_CXX_FLAGS "${_CXX_FLAGS} -fno-operator-names -fpermissive -std=c++11") # -fcxx-exceptions") ## xbyak needs exceptions endif() @@ -424,57 +420,3 @@ set(RE_CMAKE_CONFIGURED 1) - - - - - - - - - -### These were for internal testing, don't use ### -# -function(CpuIs CpuType Res) - set(${Res} OFF PARENT_SCOPE) - if (${HOST_CPU} EQUAL ${CpuType}) - set(${Res} ON PARENT_SCOPE) - endif() -endfunction() - -macro(CpuIsX86 res) - CpuIs(CPU_X86 ${res}) -endmacro() - -macro(CpuIsX64 res) - CpuIs(CPU_X64 ${res}) -endmacro() - -macro(CpuIsARM res) - CpuIs(CPU_ARM ${res}) -endmacro() - -macro(CpuIsA64 res) - CpuIs(CPU_A64 ${res}) -endmacro() - -macro(CpuIsPPC res) - CpuIs(CPU_PPC ${res}) -endmacro() - -macro(CpuIsPPC64 res) - CpuIs(CPU_PPC64 ${res}) -endmacro() - -macro(CpuIsMIPS res) - CpuIs(CPU_MIPS ${res}) -endmacro() - -macro(CpuIsMIPS64 res) - CpuIs(CPU_MIPS64 ${res}) -endmacro() - - - - - From aa8a922b6241e5b431a97f1317b5d42862feb5dc Mon Sep 17 00:00:00 2001 From: Braden Farmer Date: Tue, 16 Apr 2019 23:38:33 -0600 Subject: [PATCH 42/73] Android: remove duplicate intent filters The latest reicast builds displayed a redundant second launcher icon in the app drawer, due to a change in #1548. This fixes the issue by removing the duplicate intent filters causing the redundant icon to display. --- .../reicast/src/dreamcast/AndroidManifest.xml | 52 +--------------- .../reicast/src/main/AndroidManifest.xml | 10 +--- .../reicast/src/naomi/AndroidManifest.xml | 60 +------------------ 3 files changed, 5 insertions(+), 117 deletions(-) diff --git a/shell/android-studio/reicast/src/dreamcast/AndroidManifest.xml b/shell/android-studio/reicast/src/dreamcast/AndroidManifest.xml index 112f56962..d0a0cfb3b 100644 --- a/shell/android-studio/reicast/src/dreamcast/AndroidManifest.xml +++ b/shell/android-studio/reicast/src/dreamcast/AndroidManifest.xml @@ -3,55 +3,7 @@ xmlns:tools="http://schemas.android.com/tools"> - - - - - - - - - - - - - - - - + android:name="com.reicast.emulator.NativeGLActivity"/> @@ -104,4 +56,4 @@ - \ No newline at end of file + diff --git a/shell/android-studio/reicast/src/main/AndroidManifest.xml b/shell/android-studio/reicast/src/main/AndroidManifest.xml index ac89e2bb2..bc93a562f 100644 --- a/shell/android-studio/reicast/src/main/AndroidManifest.xml +++ b/shell/android-studio/reicast/src/main/AndroidManifest.xml @@ -53,14 +53,8 @@ - - - - - - - + android:screenOrientation="sensorLandscape" + android:exported="true"/> diff --git a/shell/android-studio/reicast/src/naomi/AndroidManifest.xml b/shell/android-studio/reicast/src/naomi/AndroidManifest.xml index 32fceb16c..a1a4c24b2 100644 --- a/shell/android-studio/reicast/src/naomi/AndroidManifest.xml +++ b/shell/android-studio/reicast/src/naomi/AndroidManifest.xml @@ -3,65 +3,7 @@ android:name="com.reicast.emulator.Emulator"> - - - - - - - - - - - - - - - - - - + android:name="com.reicast.emulator.NativeGLActivity"/> From 0a3c361da2adce112f43964bd86ae6126d81dd34 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Wed, 24 Apr 2019 21:41:38 +0200 Subject: [PATCH 43/73] AUDIO: Allow backend specific settings --- core/nullDC.cpp | 20 ++++++ core/oslib/audiobackend_alsa.cpp | 71 ++++++++++++++++++- core/oslib/audiobackend_omx.cpp | 3 +- core/oslib/audiobackend_oss.cpp | 3 +- core/oslib/audiobackend_pulseaudio.cpp | 3 +- core/oslib/audiostream.h | 24 +++++++ core/rend/gui.cpp | 53 +++++++++++++- core/types.h | 8 ++- .../reicast/src/main/jni/src/Android.cpp | 3 +- 9 files changed, 181 insertions(+), 7 deletions(-) diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 2f673fc5f..1deeebad7 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -721,6 +721,26 @@ void SaveSettings() cfgSaveBool("config", "aica.NoBatch", settings.aica.NoBatch); cfgSaveBool("config", "aica.NoSound", settings.aica.NoSound); cfgSaveStr("audio", "backend", settings.audio.backend.c_str()); + + // Write backend specific settings + // std::map> + for (std::map>::iterator it = settings.audio.options.begin(); it != settings.audio.options.end(); ++it) + { + + std::pair> p = (std::pair>)*it; + std::string section = p.first; + std::map options = p.second; + + for (std::map::iterator it2 = options.begin(); it2 != options.end(); ++it2) + { + std::pair p2 = (std::pair)*it2; + std::string key = p2.first; + std::string val = p2.second; + + cfgSaveStr(section.c_str(), key.c_str(), val.c_str()); + } + } + cfgSaveBool("config", "rend.WideScreen", settings.rend.WideScreen); cfgSaveBool("config", "rend.ShowFPS", settings.rend.ShowFPS); if (!rtt_to_buffer_game || !settings.rend.RenderToTextureBuffer) diff --git a/core/oslib/audiobackend_alsa.cpp b/core/oslib/audiobackend_alsa.cpp index 2ee230976..9effbcb6d 100644 --- a/core/oslib/audiobackend_alsa.cpp +++ b/core/oslib/audiobackend_alsa.cpp @@ -175,12 +175,81 @@ static void alsa_term() snd_pcm_close(handle); } +std::vector alsa_get_devicelist() +{ + std::vector result; + + char **hints; + int err = snd_device_name_hint(-1, "pcm", (void***)&hints); + + // Error initializing ALSA + if (err != 0) + return result; + + + char** n = hints; + while (*n != NULL) + { + // Get the type (NULL/Input/Output) + char *type = snd_device_name_get_hint(*n, "IOID"); + char *name = snd_device_name_get_hint(*n, "NAME"); + + if (name != NULL) + { + // We only want output or special devices (like "default" or "pulse") + // TODO Only those with type == NULL? + if (type == NULL || strcmp(type, "Output") == 0) + { + // TODO Check if device works (however we need to hash the resulting list then) + /*snd_pcm_t *handle; + int rc = snd_pcm_open(&handle, name, SND_PCM_STREAM_PLAYBACK, 0); + + if (rc == 0) + { + result.push_back(name); + snd_pcm_close(handle); + } + */ + + result.push_back(name); + } + + } + + if (type != NULL) + free(type); + + if (name != NULL) + free(name); + + n++; + } + + snd_device_name_free_hint((void**)hints); + + return result; +} + +static audio_option_t* alsa_audio_options(int* option_count) +{ + *option_count = 1; + static audio_option_t result[1]; + + result[0].cfg_name = "device"; + result[0].caption = "Device"; + result[0].type = list; + result[0].list_callback = alsa_get_devicelist; + + return result; +} + static audiobackend_t audiobackend_alsa = { "alsa", // Slug "Advanced Linux Sound Architecture", // Name &alsa_init, &alsa_push, - &alsa_term + &alsa_term, + &alsa_audio_options }; static bool alsa = RegisterAudioBackend(&audiobackend_alsa); diff --git a/core/oslib/audiobackend_omx.cpp b/core/oslib/audiobackend_omx.cpp index 71c426b68..c8c8a6536 100644 --- a/core/oslib/audiobackend_omx.cpp +++ b/core/oslib/audiobackend_omx.cpp @@ -313,7 +313,8 @@ audiobackend_t audiobackend_omx = { "OpenMAX IL", // Name &omx_init, &omx_push, - &omx_term + &omx_term, + NULL }; static bool omx = RegisterAudioBackend(&audiobackend_omx); diff --git a/core/oslib/audiobackend_oss.cpp b/core/oslib/audiobackend_oss.cpp index cc653466f..b3a48cbd6 100644 --- a/core/oslib/audiobackend_oss.cpp +++ b/core/oslib/audiobackend_oss.cpp @@ -48,7 +48,8 @@ audiobackend_t audiobackend_oss = { "Open Sound System", // Name &oss_init, &oss_push, - &oss_term + &oss_term, + NULL }; static bool oss = RegisterAudioBackend(&audiobackend_oss); diff --git a/core/oslib/audiobackend_pulseaudio.cpp b/core/oslib/audiobackend_pulseaudio.cpp index 28963b00a..b651b4003 100644 --- a/core/oslib/audiobackend_pulseaudio.cpp +++ b/core/oslib/audiobackend_pulseaudio.cpp @@ -43,7 +43,8 @@ audiobackend_t audiobackend_pulseaudio = { "PulseAudio", // Name &pulseaudio_init, &pulseaudio_push, - &pulseaudio_term + &pulseaudio_term, + NULL }; static bool pulse = RegisterAudioBackend(&audiobackend_pulseaudio); diff --git a/core/oslib/audiostream.h b/core/oslib/audiostream.h index 2726db0e1..37c1cbc43 100644 --- a/core/oslib/audiostream.h +++ b/core/oslib/audiostream.h @@ -11,6 +11,29 @@ u32 asRingFreeCount(); bool asRingRead(u8* dst,u32 count=0); void UpdateBuff(u8* pos); +typedef std::vector (*audio_option_callback_t)(); +enum audio_option_type +{ + text = 0 +, integer = 1 +, list = 2 +}; + +typedef struct { + std::string cfg_name; + std::string caption; + audio_option_type type; + + // type int_value (spin edit) + int min_value; + int max_value; + + // type list edit (string/char*) + audio_option_callback_t list_callback; +} audio_option_t; + +typedef audio_option_t* (*audio_options_func_t)(int* option_count); + typedef void (*audio_backend_init_func_t)(); typedef u32 (*audio_backend_push_func_t)(void*, u32, bool); typedef void (*audio_backend_term_func_t)(); @@ -20,6 +43,7 @@ typedef struct { audio_backend_init_func_t init; audio_backend_push_func_t push; audio_backend_term_func_t term; + audio_options_func_t get_options; } audiobackend_t; extern bool RegisterAudioBackend(audiobackend_t* backend); extern void InitAudio(); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index a530f5b5c..008ed1041 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -1036,6 +1036,8 @@ static void gui_display_settings() } SortAudioBackends(); + + audiobackend_t* current_backend = backend; if (ImGui::BeginCombo("Audio Backend", backend_name.c_str(), ImGuiComboFlags_None)) { bool is_selected = (settings.audio.backend == "auto"); @@ -1052,9 +1054,12 @@ static void gui_display_settings() for (int i = 0; i < GetAudioBackendCount(); i++) { - audiobackend_t* backend = GetAudioBackend(i); + backend = GetAudioBackend(i); is_selected = (settings.audio.backend == backend->slug); + if (is_selected) + current_backend = backend; + if (ImGui::Selectable(backend->slug.c_str(), &is_selected)) settings.audio.backend = backend->slug; ImGui::SameLine(); ImGui::Text("-"); @@ -1067,6 +1072,52 @@ static void gui_display_settings() ImGui::SameLine(); ShowHelpMarker("The audio backend to use"); + if (current_backend != NULL && current_backend->get_options != NULL) + { + // get backend specific options + int option_count; + audio_option_t* options = current_backend->get_options(&option_count); + + // initialize options if not already done + std::map* cfg_entries = &settings.audio.options[current_backend->slug]; + bool populate_entries = (cfg_entries->size() == 0); + + for (int o = 0; o < option_count; o++) + { + std::string value; + if (populate_entries) + { + value = cfgLoadStr(current_backend->slug.c_str(), options->cfg_name.c_str(), ""); + (*cfg_entries)[options->cfg_name] = value; + } + value = (*cfg_entries)[options->cfg_name]; + + if (options->type == list) + { + if (ImGui::BeginCombo(options->caption.c_str(), value.c_str(), ImGuiComboFlags_None)) + { + bool is_selected = false; + std::vector list_items = options->list_callback(); + for (std::vector::iterator it = list_items.begin() ; it != list_items.end(); ++it) + { + std::string cur = (std::string)*it; + is_selected = (value == cur); + if (ImGui::Selectable(cur.c_str(), &is_selected)) + { + (*cfg_entries)[options->cfg_name] = cur; + } + + if (is_selected) + ImGui::SetItemDefaultFocus(); + } + ImGui::EndCombo(); + } + } + + options++; + } + } + ImGui::Checkbox("Enable DSP", &settings.aica.NoBatch); ImGui::SameLine(); ShowHelpMarker("Enable the Dreamcast Digital Sound Processor. Only recommended on fast and arm64 platforms"); diff --git a/core/types.h b/core/types.h index 771d758e6..8b1a039a8 100644 --- a/core/types.h +++ b/core/types.h @@ -344,6 +344,7 @@ int darw_printf(const wchar* Text,...); //includes from c++rt #include #include +#include using namespace std; //used for asm-olny functions @@ -387,7 +388,7 @@ using namespace std; #ifndef RELEASE #define EMUERROR(format, ...) printf("Error in %20s:%s:%d: " format "\n", \ __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__) -//strlen(__FILE__) <= 20 ? __FILE__ : __FILE__ + strlen(__FILE__) - 20, +//strlen(__FILE__) <= 20 ? __FILE__ : __FILE__ + strlen(__FILE__) - 20, #else #define EMUERROR(format, ...) #endif @@ -681,7 +682,12 @@ struct settings_t struct{ std::string backend; + + // slug<> + std::map> options; } audio; + + #if USE_OMX struct { diff --git a/shell/android-studio/reicast/src/main/jni/src/Android.cpp b/shell/android-studio/reicast/src/main/jni/src/Android.cpp index 7b6ad5533..07521e6ee 100644 --- a/shell/android-studio/reicast/src/main/jni/src/Android.cpp +++ b/shell/android-studio/reicast/src/main/jni/src/Android.cpp @@ -547,7 +547,8 @@ audiobackend_t audiobackend_android = { "Android Audio", // Name &androidaudio_init, &androidaudio_push, - &androidaudio_term + &androidaudio_term, + NULL }; static bool android = RegisterAudioBackend(&audiobackend_android); From 7b50d5df8c48d74e7091ad05b351e04c2c468ab6 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 27 Apr 2019 12:05:13 +0200 Subject: [PATCH 44/73] Add ENABLE_MODEM and rework makefiles to support it. --- core/core.mk | 51 +++++++++++++++++++--------------------- core/hw/holly/sb.cpp | 2 +- core/hw/holly/sb_mem.cpp | 6 +++-- core/serialize.cpp | 12 +++++----- shell/linux/Makefile | 10 +------- 5 files changed, 36 insertions(+), 45 deletions(-) diff --git a/core/core.mk b/core/core.mk index 1337c531a..4573ba5e7 100755 --- a/core/core.mk +++ b/core/core.mk @@ -7,20 +7,11 @@ RZDCY_SRC_DIR ?= $(call my-dir) VERSION_HEADER := $(RZDCY_SRC_DIR)/version.h -RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ hw/modem/ \ +RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ \ hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/interpr/ hw/sh4/modules/ plugins/ profiler/ oslib/ \ hw/extdev/ hw/arm/ hw/naomi/ imgread/ ./ deps/coreio/ deps/zlib/ deps/chdr/ deps/crypto/ \ deps/libelf/ deps/chdpsr/ arm_emitter/ rend/ reios/ deps/libpng/ deps/xbrz/ \ - deps/picotcp/modules/ deps/picotcp/stack/ deps/xxhash/ deps/libzip/ deps/imgui/ \ - archive/ input/ - -ifdef CHD5_LZMA - RZDCY_MODULES += deps/lzma/ -endif - -ifdef CHD5_FLAC - RZDCY_MODULES += deps/flac/src/libFLAC/ -endif + deps/xxhash/ deps/libzip/ deps/imgui/ archive/ input/ ifdef WEBUI RZDCY_MODULES += webui/ @@ -31,10 +22,6 @@ ifdef WEBUI endif endif -ifndef NO_REC - RZDCY_MODULES += hw/sh4/dyna/ -endif - ifndef NOT_ARM RZDCY_MODULES += rec-ARM/ endif @@ -66,10 +53,6 @@ else RZDCY_MODULES += rend/norend/ endif -ifdef HAS_SOFTREND - RZDCY_MODULES += rend/soft/ -endif - ifndef NO_NIXPROF RZDCY_MODULES += linux/nixprof/ endif @@ -90,11 +73,6 @@ ifdef FOR_WINDOWS RZDCY_MODULES += windows/ endif -RZDCY_FILES := $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cpp)) -RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cc)) -RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.c)) -RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.S)) - ifdef FOR_PANDORA RZDCY_CFLAGS := \ $(CFLAGS) -c -O3 \ @@ -133,11 +111,17 @@ RZDCY_CFLAGS := endif RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/rend/gles -I$(RZDCY_SRC_DIR)/deps \ - -I$(RZDCY_SRC_DIR)/deps/picotcp/include -I$(RZDCY_SRC_DIR)/deps/picotcp/modules \ -I$(RZDCY_SRC_DIR)/deps/vixl -I$(RZDCY_SRC_DIR)/khronos +ifdef USE_MODEM + RZDCY_CFLAGS += -DENABLE_MODEM -I$(RZDCY_SRC_DIR)/deps/picotcp/include -I$(RZDCY_SRC_DIR)/deps/picotcp/modules + RZDCY_MODULES += hw/modem/ deps/picotcp/modules/ deps/picotcp/stack/ +endif + ifdef NO_REC - RZDCY_CFLAGS += -DTARGET_NO_REC + RZDCY_CFLAGS += -DTARGET_NO_REC +else + RZDCY_MODULES += hw/sh4/dyna/ endif ifdef USE_GLES @@ -146,15 +130,28 @@ endif ifdef HAS_SOFTREND RZDCY_CFLAGS += -DTARGET_SOFTREND + RZDCY_MODULES += rend/soft/ endif ifdef CHD5_FLAC - RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR)/deps/flac/src/libFLAC/include/ -I$(RZDCY_SRC_DIR)/deps/flac/include + RZDCY_CFLAGS += -DCHD5_FLAC -I$(RZDCY_SRC_DIR)/deps/flac/src/libFLAC/include/ -I$(RZDCY_SRC_DIR)/deps/flac/include RZDCY_CFLAGS += -DPACKAGE_VERSION=\"1.3.2\" -DFLAC__HAS_OGG=0 -DFLAC__NO_DLL -DHAVE_LROUND -DHAVE_STDINT_H -DHAVE_STDLIB_H -DHAVE_SYS_PARAM_H + RZDCY_MODULES += deps/flac/src/libFLAC/ +endif + +# 7-Zip/LZMA settings (CHDv5) +ifdef CHD5_LZMA + RZDCY_MODULES += deps/lzma/ + RZDCY_CFLAGS += -D_7ZIP_ST -DCHD5_LZMA endif RZDCY_CXXFLAGS := $(RZDCY_CFLAGS) -fno-exceptions -fno-rtti -std=gnu++11 +RZDCY_FILES := $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cpp)) +RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cc)) +RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.c)) +RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.S)) + $(VERSION_HEADER): echo "#define REICAST_VERSION \"`git describe --tags --always`\"" > $(VERSION_HEADER) echo "#define GIT_HASH \"`git rev-parse --short HEAD`\"" >> $(VERSION_HEADER) diff --git a/core/hw/holly/sb.cpp b/core/hw/holly/sb.cpp index 69c809a82..4c962b6f6 100644 --- a/core/hw/holly/sb.cpp +++ b/core/hw/holly/sb.cpp @@ -783,7 +783,7 @@ void sb_Init() maple_Init(); aica_sb_Init(); -#if DC_PLATFORM == DC_PLATFORM_DREAMCAST +#if DC_PLATFORM == DC_PLATFORM_DREAMCAST && defined(ENABLE_MODEM) ModemInit(); #endif } diff --git a/core/hw/holly/sb_mem.cpp b/core/hw/holly/sb_mem.cpp index d201550c3..c60e4a7ba 100644 --- a/core/hw/holly/sb_mem.cpp +++ b/core/hw/holly/sb_mem.cpp @@ -217,8 +217,10 @@ T DYNACALL ReadMem_area0(u32 addr) { #if DC_PLATFORM == DC_PLATFORM_NAOMI || DC_PLATFORM == DC_PLATFORM_ATOMISWAVE return (T)libExtDevice_ReadMem_A0_006(addr, sz); -#else +#elif defined(ENABLE_MODEM) return (T)ModemReadMem_A0_006(addr, sz); +#else + return (T)0; #endif } //map 0x0060 to 0x006F @@ -302,7 +304,7 @@ void DYNACALL WriteMem_area0(u32 addr,T data) { #if DC_PLATFORM == DC_PLATFORM_NAOMI || DC_PLATFORM == DC_PLATFORM_ATOMISWAVE libExtDevice_WriteMem_A0_006(addr, data, sz); -#else +#elif defined(ENABLE_MODEM) ModemWriteMem_A0_006(addr, data, sz); #endif } diff --git a/core/serialize.cpp b/core/serialize.cpp index 9d28fd068..1d7fec35b 100644 --- a/core/serialize.cpp +++ b/core/serialize.cpp @@ -1046,11 +1046,11 @@ bool dc_serialize(void **data, unsigned int *total_size) REICAST_S(sch_list[time_sync].start) ; REICAST_S(sch_list[time_sync].end) ; + #ifdef ENABLE_MODEM REICAST_S(sch_list[modem_sched].tag) ; REICAST_S(sch_list[modem_sched].start) ; REICAST_S(sch_list[modem_sched].end) ; - - + #endif REICAST_S(SCIF_SCFSR2); REICAST_S(SCIF_SCFRDR2); @@ -1448,11 +1448,11 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(sch_list[time_sync].start) ; REICAST_US(sch_list[time_sync].end) ; + #ifdef ENABLE_MODEM REICAST_US(sch_list[modem_sched].tag) ; REICAST_US(sch_list[modem_sched].start) ; REICAST_US(sch_list[modem_sched].end) ; - - + #endif REICAST_US(SCIF_SCFSR2); REICAST_US(SCIF_SCFRDR2); @@ -1838,11 +1838,11 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_US(sch_list[time_sync].start) ; REICAST_US(sch_list[time_sync].end) ; + #ifdef ENABLE_MODEM REICAST_US(sch_list[modem_sched].tag) ; REICAST_US(sch_list[modem_sched].start) ; REICAST_US(sch_list[modem_sched].end) ; - - + #endif REICAST_US(SCIF_SCFSR2); REICAST_US(SCIF_SCFRDR2); diff --git a/shell/linux/Makefile b/shell/linux/Makefile index 6af3aed05..d182e0601 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -9,6 +9,7 @@ USE_OSS := 1 #USE_LIBAO := 1 USE_EVDEV := 1 USE_UDEV := 1 +USE_MODEM := 1 PLATFORM_EXT := elf CXX=${CC_PREFIX}g++ @@ -265,15 +266,6 @@ else $(error Unknown platform) endif -# 7-Zip/LZMA settings (CHDv5) -ifdef CHD5_LZMA - CFLAGS += -D_7ZIP_ST -DCHD5_LZMA -endif - -ifdef CHD5_FLAC - CFLAGS += -DCHD5_FLAC -endif - RZDCY_SRC_DIR = $(LOCAL_PATH)/../../core include $(RZDCY_SRC_DIR)/core.mk From 3692ea7ae609dbfd5cfccc58c7b1d2cb540f8961 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 27 Apr 2019 14:08:43 +0200 Subject: [PATCH 45/73] Improve stdclass.h/cpp support for non-Linux non-Windows platforms Simplifies having implementation on platform separated files, which is a pain for platforms which are not Windows but not Linux either (and yet support pthreads). Some minor cleanup here and there while we are at it. --- core/hw/pvr/Renderer_if.cpp | 3 +- core/hw/pvr/ta_ctx.cpp | 2 +- core/linux/common.cpp | 103 ------------------- core/rend/gles/CustomTexture.h | 4 +- core/stdclass.cpp | 181 +++++++++++++++++++++++++-------- core/stdclass.h | 27 ++--- core/windows/winmain.cpp | 72 ------------- 7 files changed, 155 insertions(+), 237 deletions(-) diff --git a/core/hw/pvr/Renderer_if.cpp b/core/hw/pvr/Renderer_if.cpp index fc4db314d..0a9c5b16b 100644 --- a/core/hw/pvr/Renderer_if.cpp +++ b/core/hw/pvr/Renderer_if.cpp @@ -82,8 +82,7 @@ bool renderer_enabled = true; // Signals the renderer thread to exit bool renderer_changed = false; // Signals the renderer thread to switch renderer #if !defined(TARGET_NO_THREADS) -cResetEvent rs(false,true); -cResetEvent re(false,true); +cResetEvent rs, re; #endif int max_idx,max_mvo,max_op,max_pt,max_tr,max_vtx,max_modt, ovrn; diff --git a/core/hw/pvr/ta_ctx.cpp b/core/hw/pvr/ta_ctx.cpp index 781d82aa4..31e80b07e 100644 --- a/core/hw/pvr/ta_ctx.cpp +++ b/core/hw/pvr/ta_ctx.cpp @@ -124,7 +124,7 @@ void VDecEnd() cMutex mtx_rqueue; TA_context* rqueue; -cResetEvent frame_finished(false, true); +cResetEvent frame_finished; double last_frame = 0; u64 last_cyces = 0; diff --git a/core/linux/common.cpp b/core/linux/common.cpp index 7b6db0f7f..98ffca196 100644 --- a/core/linux/common.cpp +++ b/core/linux/common.cpp @@ -130,109 +130,6 @@ void install_fault_handler (void) #endif } -#if !defined(TARGET_NO_THREADS) - -//Thread class -cThread::cThread(ThreadEntryFP* function,void* prm) -{ - Entry=function; - param=prm; -} - -void cThread::Start() -{ - verify(hThread == NULL); - if (pthread_create( (pthread_t*)&hThread, NULL, Entry, param)) - { - die("Thread creation failed"); - } -} - -void cThread::WaitToEnd() -{ - if (hThread != NULL) - { - pthread_join((pthread_t)hThread,0); - hThread = NULL; - } -} - -//End thread class -#endif - -//cResetEvent Calss -cResetEvent::cResetEvent(bool State,bool Auto) -{ - //sem_init((sem_t*)hEvent, 0, State?1:0); - verify(State==false&&Auto==true); - pthread_mutex_init(&mutx, NULL); - pthread_cond_init(&cond, NULL); -} -cResetEvent::~cResetEvent() -{ - //Destroy the event object ? - -} -void cResetEvent::Set()//Signal -{ - pthread_mutex_lock( &mutx ); - state=true; - pthread_cond_signal( &cond); - pthread_mutex_unlock( &mutx ); -} -void cResetEvent::Reset()//reset -{ - pthread_mutex_lock( &mutx ); - state=false; - pthread_mutex_unlock( &mutx ); -} -bool cResetEvent::Wait(u32 msec)//Wait for signal , then reset -{ - pthread_mutex_lock( &mutx ); - if (!state) - { - struct timespec ts; -#if HOST_OS == OS_DARWIN - // OSX doesn't have clock_gettime. - clock_serv_t cclock; - mach_timespec_t mts; - - host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); - clock_get_time(cclock, &mts); - mach_port_deallocate(mach_task_self(), cclock); - ts.tv_sec = mts.tv_sec; - ts.tv_nsec = mts.tv_nsec; -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif - ts.tv_sec += msec / 1000; - ts.tv_nsec += (msec % 1000) * 1000000; - while (ts.tv_nsec > 1000000000) - { - ts.tv_nsec -= 1000000000; - ts.tv_sec++; - } - pthread_cond_timedwait( &cond, &mutx, &ts ); - } - bool rc = state; - state=false; - pthread_mutex_unlock( &mutx ); - - return rc; -} -void cResetEvent::Wait()//Wait for signal , then reset -{ - pthread_mutex_lock( &mutx ); - if (!state) - { - pthread_cond_wait( &cond, &mutx ); - } - state=false; - pthread_mutex_unlock( &mutx ); -} - -//End AutoResetEvent - #include void VArray2::LockRegion(u32 offset,u32 size) diff --git a/core/rend/gles/CustomTexture.h b/core/rend/gles/CustomTexture.h index 830855542..fd8a00db1 100644 --- a/core/rend/gles/CustomTexture.h +++ b/core/rend/gles/CustomTexture.h @@ -29,9 +29,9 @@ public: CustomTexture() : #ifndef TARGET_NO_THREADS - loader_thread(loader_thread_func, this), + loader_thread(loader_thread_func, this) #endif - wakeup_thread(false, true) {} + {} ~CustomTexture() { Terminate(); } u8* LoadCustomTexture(u32 hash, int& width, int& height); void LoadCustomTextureAsync(TextureCacheData *texture_data); diff --git a/core/stdclass.cpp b/core/stdclass.cpp index ca773ee24..05cc49013 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -4,6 +4,7 @@ #include #include "types.h" #include "cfg/cfg.h" +#include "stdclass.h" #if COMPILER_VC_OR_CLANG_WIN32 @@ -153,55 +154,145 @@ bool make_directory(const string& path) #endif } -#if 0 -//File Enumeration -void FindAllFiles(FileFoundCB* callback,wchar* dir,void* param) -{ - WIN32_FIND_DATA FindFileData; - HANDLE hFind = INVALID_HANDLE_VALUE; - wchar DirSpec[MAX_PATH + 1]; // directory specification - DWORD dwError; +// Thread & related platform dependant code +#if !defined(HOST_NO_THREADS) - strncpy (DirSpec, dir, strlen(dir)+1); - //strncat (DirSpec, "\\*", 3); - - hFind = FindFirstFile( DirSpec, &FindFileData); - - if (hFind == INVALID_HANDLE_VALUE) - { - return; - } - else - { - - if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)==0) - { - callback(FindFileData.cFileName,param); - } -u32 rv; - while ( (rv=FindNextFile(hFind, &FindFileData)) != 0) - { - if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)==0) - { - callback(FindFileData.cFileName,param); - } - } - dwError = GetLastError(); - FindClose(hFind); - if (dwError != ERROR_NO_MORE_FILES) - { - return ; - } +#if HOST_OS==OS_WINDOWS +void cThread::Start() { + verify(hThread == NULL); + hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)entry, param, 0, NULL); + ResumeThread(hThread); +} +void cThread::WaitToEnd() { + WaitForSingleObject(hThread,INFINITE); + CloseHandle(hThread); + hThread = NULL; +} +#else +void cThread::Start() { + verify(hThread == NULL); + hThread = new pthread_t; + if (pthread_create( hThread, NULL, entry, param)) + die("Thread creation failed"); +} +void cThread::WaitToEnd() { + if (hThread) { + pthread_join(*hThread,0); + delete hThread; + hThread = NULL; } - return ; } #endif -/* -#include "dc\sh4\rec_v1\compiledblock.h" -#include "dc\sh4\rec_v1\blockmanager.h" +#endif + + +#if HOST_OS==OS_WINDOWS +cResetEvent::cResetEvent() { + hEvent = CreateEvent( + NULL, // default security attributes + FALSE, // auto-reset event? + FALSE, // initial state is State + NULL // unnamed object + ); +} +cResetEvent::~cResetEvent() +{ + //Destroy the event object ? + CloseHandle(hEvent); +} +void cResetEvent::Set()//Signal +{ + #if defined(DEBUG_THREADS) + Sleep(rand() % 10); + #endif + SetEvent(hEvent); +} +void cResetEvent::Reset()//reset +{ + #if defined(DEBUG_THREADS) + Sleep(rand() % 10); + #endif + ResetEvent(hEvent); +} +bool cResetEvent::Wait(u32 msec)//Wait for signal , then reset +{ + #if defined(DEBUG_THREADS) + Sleep(rand() % 10); + #endif + return WaitForSingleObject(hEvent,msec) == WAIT_OBJECT_0; +} +void cResetEvent::Wait()//Wait for signal , then reset +{ + #if defined(DEBUG_THREADS) + Sleep(rand() % 10); + #endif + WaitForSingleObject(hEvent,(u32)-1); +} +#else +cResetEvent::cResetEvent() { + pthread_mutex_init(&mutx, NULL); + pthread_cond_init(&cond, NULL); +} +cResetEvent::~cResetEvent() { +} +void cResetEvent::Set()//Signal +{ + pthread_mutex_lock( &mutx ); + state=true; + pthread_cond_signal( &cond); + pthread_mutex_unlock( &mutx ); +} +void cResetEvent::Reset()//reset +{ + pthread_mutex_lock( &mutx ); + state=false; + pthread_mutex_unlock( &mutx ); +} +bool cResetEvent::Wait(u32 msec)//Wait for signal , then reset +{ + pthread_mutex_lock( &mutx ); + if (!state) + { + struct timespec ts; +#if HOST_OS == OS_DARWIN + // OSX doesn't have clock_gettime. + clock_serv_t cclock; + mach_timespec_t mts; + + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + ts.tv_sec = mts.tv_sec; + ts.tv_nsec = mts.tv_nsec; +#else + clock_gettime(CLOCK_REALTIME, &ts); +#endif + ts.tv_sec += msec / 1000; + ts.tv_nsec += (msec % 1000) * 1000000; + while (ts.tv_nsec > 1000000000) + { + ts.tv_nsec -= 1000000000; + ts.tv_sec++; + } + pthread_cond_timedwait( &cond, &mutx, &ts ); + } + bool rc = state; + state=false; + pthread_mutex_unlock( &mutx ); + + return rc; +} +void cResetEvent::Wait()//Wait for signal , then reset +{ + pthread_mutex_lock( &mutx ); + if (!state) + { + pthread_cond_wait( &cond, &mutx ); + } + state=false; + pthread_mutex_unlock( &mutx ); +} +#endif -bool VramLockedWrite(u8* address); -bool RamLockedWrite(u8* address,u32* sp); -*/ diff --git a/core/stdclass.h b/core/stdclass.h index 0c30dd534..f5e87e6cb 100644 --- a/core/stdclass.h +++ b/core/stdclass.h @@ -166,38 +166,41 @@ public: #if !defined(HOST_NO_THREADS) typedef void* ThreadEntryFP(void* param); -typedef void* THREADHANDLE; - -class cThread -{ +class cThread { private: - ThreadEntryFP* Entry; + ThreadEntryFP* entry; void* param; public : - THREADHANDLE hThread; - cThread(ThreadEntryFP* function,void* param); - + #if HOST_OS==OS_WINDOWS + HANDLE hThread; + #else + pthread_t *hThread; + #endif + + cThread(ThreadEntryFP* function, void* param) + :entry(function), param(param), hThread(NULL) {} + ~cThread() { WaitToEnd(); } void Start(); void WaitToEnd(); }; #endif + + //Wait Events typedef void* EVENTHANDLE; class cResetEvent { - private: #if HOST_OS==OS_WINDOWS EVENTHANDLE hEvent; #else pthread_mutex_t mutx; pthread_cond_t cond; - + bool state; #endif public : - bool state; - cResetEvent(bool State,bool Auto); + cResetEvent(); ~cResetEvent(); void Set(); //Set state to signaled void Reset(); //Set state to non signaled diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 7e269a90d..27d651dd4 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -750,78 +750,6 @@ void os_DoEvents() } - - -//Windoze Code implementation of commong classes from here and after .. - -//Thread class -cThread::cThread(ThreadEntryFP* function,void* prm) -{ - Entry=function; - param=prm; -} - - -void cThread::Start() -{ - verify(hThread == NULL); - hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Entry,param,0,NULL); - ResumeThread(hThread); -} - -void cThread::WaitToEnd() -{ - WaitForSingleObject(hThread,INFINITE); - CloseHandle(hThread); - hThread = NULL; -} -//End thread class - -//cResetEvent Calss -cResetEvent::cResetEvent(bool State,bool Auto) -{ - hEvent = CreateEvent( - NULL, // default security attributes - Auto?FALSE:TRUE, // auto-reset event? - State?TRUE:FALSE, // initial state is State - NULL // unnamed object - ); -} -cResetEvent::~cResetEvent() -{ - //Destroy the event object ? - CloseHandle(hEvent); -} -void cResetEvent::Set()//Signal -{ - #if defined(DEBUG_THREADS) - Sleep(rand() % 10); - #endif - SetEvent(hEvent); -} -void cResetEvent::Reset()//reset -{ - #if defined(DEBUG_THREADS) - Sleep(rand() % 10); - #endif - ResetEvent(hEvent); -} -bool cResetEvent::Wait(u32 msec)//Wait for signal , then reset -{ - #if defined(DEBUG_THREADS) - Sleep(rand() % 10); - #endif - return WaitForSingleObject(hEvent,msec) == WAIT_OBJECT_0; -} -void cResetEvent::Wait()//Wait for signal , then reset -{ - #if defined(DEBUG_THREADS) - Sleep(rand() % 10); - #endif - WaitForSingleObject(hEvent,(u32)-1); -} -//End AutoResetEvent - void VArray2::LockRegion(u32 offset,u32 size) { //verify(offset+sizesize); From d6f682a32937fc9e1b91dfe120c7951018324d7a Mon Sep 17 00:00:00 2001 From: David Miller Date: Wed, 1 May 2019 12:01:45 -0400 Subject: [PATCH 46/73] audiostream only wait if at speed --- core/oslib/audiostream.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/oslib/audiostream.cpp b/core/oslib/audiostream.cpp index ea6845bed..b07666b7a 100644 --- a/core/oslib/audiostream.cpp +++ b/core/oslib/audiostream.cpp @@ -117,10 +117,14 @@ audiobackend_t* GetAudioBackend(std::string slug) return NULL; } +extern double full_rps; + u32 PushAudio(void* frame, u32 amt, bool wait) { + bool do_wait = (full_rps<50.f)?false:wait; + if (audiobackend_current != NULL) { - return audiobackend_current->push(frame, amt, wait); + return audiobackend_current->push(frame, amt, do_wait); } return 0; } From c681dc77dc8a2d7b9b8d12dc6291c2fe9eed692f Mon Sep 17 00:00:00 2001 From: david miller Date: Wed, 1 May 2019 19:11:35 -0400 Subject: [PATCH 47/73] Win32 fullscreen via alt-enter --- CMakeLists.txt | 2 +- core/windows/winmain.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a757f3d0..80342e0d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,7 @@ if(${BUILD_COMPILER} EQUAL ${COMPILER_GCC}) # Add Clang if NOT WIN32 *FIXME* ${lzma_SRCS} ${pico_SRCS} ) + add_definitions(-D_7ZIP_ST -DCHD5_LZMA) endif() ### libosd.cmake ################################################################################ @@ -243,7 +244,6 @@ endif() include_directories ("${reicast_core_path}") -add_definitions(-D_7ZIP_ST -DCHD5_LZMA) diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 27d651dd4..029ba1246 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -198,6 +198,10 @@ extern f32 mo_wheel_delta; // Keyboard static Win32KeyboardDevice keyboard(0); + +void ToggleFullscreen(); + + void UpdateInputState(u32 port) { /* @@ -331,6 +335,14 @@ LRESULT CALLBACK WndProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) keyboard.keyboard_input(keycode, message == WM_KEYDOWN); } break; + + case WM_SYSKEYDOWN: + if (wParam == VK_RETURN) + if ((HIWORD(lParam) & KF_ALTDOWN)) + ToggleFullscreen(); + + break; + case WM_CHAR: keyboard.keyboard_character((char)wParam); return 0; @@ -388,6 +400,45 @@ void* libPvr_GetRenderSurface() return GetDC((HWND)window_win); } + +void ToggleFullscreen() +{ + static RECT rSaved; + static bool fullscreen=false; + HWND hWnd = (HWND)window_win; + + fullscreen = !fullscreen; + + + if (fullscreen) + { + GetWindowRect(hWnd, &rSaved); + + MONITORINFO mi = { sizeof(mi) }; + HMONITOR hmon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + if (GetMonitorInfo(hmon, &mi)) { + + SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); + SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE); + + SetWindowPos(hWnd, HWND_TOPMOST, mi.rcMonitor.left, mi.rcMonitor.top, + mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, + SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_ASYNCWINDOWPOS); + } + } + else { + + SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); + SetWindowLongPtr(hWnd, GWL_STYLE, WS_VISIBLE | WS_OVERLAPPEDWINDOW | (window_maximized ? WS_MAXIMIZE : 0)); + + SetWindowPos(hWnd, NULL, rSaved.left, rSaved.top, + rSaved.right - rSaved.left, rSaved.bottom - rSaved.top, + SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_ASYNCWINDOWPOS|SWP_NOZORDER); + } + +} + + BOOL CtrlHandler( DWORD fdwCtrlType ) { switch( fdwCtrlType ) From ac9e6d147d67b5da8713e3658f51ed6ad010ede9 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Thu, 2 May 2019 03:21:22 +0200 Subject: [PATCH 48/73] Change speed-dependant limiting to rely on time dilation instead of frame rate. --- core/hw/pvr/spg.cpp | 4 +++- core/oslib/audiostream.cpp | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/hw/pvr/spg.cpp b/core/hw/pvr/spg.cpp index 0cf4c4d0b..b0970c3f1 100755 --- a/core/hw/pvr/spg.cpp +++ b/core/hw/pvr/spg.cpp @@ -88,6 +88,8 @@ double full_rps; static u32 lightgun_line = 0xffff; static u32 lightgun_hpos; +double mspdf; + u32 fskip=0; //called from sh4 context , should update pvr/ta state and everything else int spg_line_sched(int tag, int cycl, int jit) @@ -174,7 +176,7 @@ int spg_line_sched(int tag, int cycl, int jit) } double frames_done=spd_cpu/2; - double mspdf=1/frames_done*1000; + mspdf=1/frames_done*1000; full_rps=(spd_fps+fskip/ts); diff --git a/core/oslib/audiostream.cpp b/core/oslib/audiostream.cpp index b07666b7a..5e6a981ed 100644 --- a/core/oslib/audiostream.cpp +++ b/core/oslib/audiostream.cpp @@ -117,14 +117,10 @@ audiobackend_t* GetAudioBackend(std::string slug) return NULL; } -extern double full_rps; - u32 PushAudio(void* frame, u32 amt, bool wait) { - bool do_wait = (full_rps<50.f)?false:wait; - if (audiobackend_current != NULL) { - return audiobackend_current->push(frame, amt, do_wait); + return audiobackend_current->push(frame, amt, wait); } return 0; } @@ -144,6 +140,8 @@ u32 asRingFreeCount() return RingBufferSampleCount-asRingUsedCount(); } +extern double mspdf; +double mspdf_smooth; void WriteSample(s16 r, s16 l) { const u32 ptr=(WritePtr+1)%RingBufferSampleCount; @@ -153,7 +151,10 @@ void WriteSample(s16 r, s16 l) if (WritePtr==(SAMPLE_COUNT-1)) { - PushAudio(RingBuffer,SAMPLE_COUNT,settings.aica.LimitFPS); + mspdf_smooth = mspdf_smooth * 0.9 + mspdf * 0.1; + bool do_wait = settings.aica.LimitFPS && (mspdf_smooth <= 11); + + PushAudio(RingBuffer,SAMPLE_COUNT, do_wait); } } From f307f9d5ad47a038fd5967b69bee2563ceb61a7f Mon Sep 17 00:00:00 2001 From: David Quintana Date: Thu, 2 May 2019 03:36:10 +0200 Subject: [PATCH 49/73] Simplify. Smoothing adds no value there. --- core/oslib/audiostream.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/oslib/audiostream.cpp b/core/oslib/audiostream.cpp index 5e6a981ed..1d6f4f079 100644 --- a/core/oslib/audiostream.cpp +++ b/core/oslib/audiostream.cpp @@ -141,7 +141,6 @@ u32 asRingFreeCount() } extern double mspdf; -double mspdf_smooth; void WriteSample(s16 r, s16 l) { const u32 ptr=(WritePtr+1)%RingBufferSampleCount; @@ -151,8 +150,7 @@ void WriteSample(s16 r, s16 l) if (WritePtr==(SAMPLE_COUNT-1)) { - mspdf_smooth = mspdf_smooth * 0.9 + mspdf * 0.1; - bool do_wait = settings.aica.LimitFPS && (mspdf_smooth <= 11); + bool do_wait = settings.aica.LimitFPS && (mspdf <= 11); PushAudio(RingBuffer,SAMPLE_COUNT, do_wait); } From 684ba26ec0bd78fc98eea5b1d7bbbc3962048177 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Thu, 2 May 2019 18:41:45 +0200 Subject: [PATCH 50/73] AUDIO: Reorganize settings Move DSP and FPS above the slug selection so that all slug specific settings are after the slug selection. --- core/rend/gui.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 008ed1041..0404b503a 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -1026,6 +1026,13 @@ static void gui_display_settings() ImGui::SameLine(); ShowHelpMarker("Disable the emulator sound output"); + ImGui::Checkbox("Enable DSP", &settings.aica.NoBatch); + ImGui::SameLine(); + ShowHelpMarker("Enable the Dreamcast Digital Sound Processor. Only recommended on fast and arm64 platforms"); + ImGui::Checkbox("Limit FPS", &settings.aica.LimitFPS); + ImGui::SameLine(); + ShowHelpMarker("Use the sound output to limit the speed of the emulator. Recommended in most cases"); + audiobackend_t* backend = NULL;; std::string backend_name = settings.audio.backend; if (backend_name != "auto" && backend_name != "none") @@ -1118,12 +1125,6 @@ static void gui_display_settings() } } - ImGui::Checkbox("Enable DSP", &settings.aica.NoBatch); - ImGui::SameLine(); - ShowHelpMarker("Enable the Dreamcast Digital Sound Processor. Only recommended on fast and arm64 platforms"); - ImGui::Checkbox("Limit FPS", &settings.aica.LimitFPS); - ImGui::SameLine(); - ShowHelpMarker("Use the sound output to limit the speed of the emulator. Recommended in most cases"); ImGui::PopStyleVar(); ImGui::EndTabItem(); } From 5678556cb6ee2378a03f2ac8d318d116f10dc8a0 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Thu, 2 May 2019 18:48:09 +0200 Subject: [PATCH 51/73] ALSA: Rework initialization of pcm device As we can now configure the alsa device in the GUI, it's no longer necessary to write the first working device back to the configuration. Also there is now the "auto" device to automatically try to initialize the alsa device. --- core/oslib/audiobackend_alsa.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/core/oslib/audiobackend_alsa.cpp b/core/oslib/audiobackend_alsa.cpp index 9effbcb6d..52223d895 100644 --- a/core/oslib/audiobackend_alsa.cpp +++ b/core/oslib/audiobackend_alsa.cpp @@ -18,30 +18,43 @@ static void alsa_init() string device = cfgLoadStr("alsa", "device", ""); int rc = -1; - if (device == "") + if (device == "" || device == "auto") { printf("ALSA: trying to determine audio device\n"); - /* Open PCM device for playback. */ + + // trying default device device = "default"; rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); + // "default" didn't work, try first device if (rc < 0) { device = "plughw:0,0,0"; rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); + + if (rc < 0) + { + device = "plughw:0,0"; + rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); + } } + // first didn't work, try second if (rc < 0) { - device = "plughw:0,0"; + device = "plughw:1,0"; rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); } - if (rc >= 0) + // try pulse audio backend + if (rc < 0) { - // init successfull, write value back to config - cfgSaveStr("alsa", "device", device.c_str()); + device = "pulse"; + rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); } + + if (rc < 0) + printf("ALSA: unable to automatically determine audio device.\n"); } else { rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0); @@ -186,6 +199,8 @@ std::vector alsa_get_devicelist() if (err != 0) return result; + // special value to automatically detect on initialization + result.push_back("auto"); char** n = hints; while (*n != NULL) From dc709c604f06bb18bc8f092353ec0b7d53d1a6ce Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Thu, 2 May 2019 18:49:44 +0200 Subject: [PATCH 52/73] ALSA: prefix output with "ALSA:" --- core/oslib/audiobackend_alsa.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/core/oslib/audiobackend_alsa.cpp b/core/oslib/audiobackend_alsa.cpp index 52223d895..47c4f348c 100644 --- a/core/oslib/audiobackend_alsa.cpp +++ b/core/oslib/audiobackend_alsa.cpp @@ -62,7 +62,7 @@ static void alsa_init() if (rc < 0) { - fprintf(stderr, "unable to open PCM device %s: %s\n", device.c_str(), snd_strerror(rc)); + fprintf(stderr, "ALSA: unable to open PCM device %s: %s\n", device.c_str(), snd_strerror(rc)); return; } @@ -75,7 +75,7 @@ static void alsa_init() rc=snd_pcm_hw_params_any(handle, params); if (rc < 0) { - fprintf(stderr, "Error:snd_pcm_hw_params_any %s\n", snd_strerror(rc)); + fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_any %s\n", snd_strerror(rc)); return; } @@ -85,7 +85,7 @@ static void alsa_init() rc=snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED); if (rc < 0) { - fprintf(stderr, "Error:snd_pcm_hw_params_set_access %s\n", snd_strerror(rc)); + fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_access %s\n", snd_strerror(rc)); return; } @@ -93,7 +93,7 @@ static void alsa_init() rc=snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE); if (rc < 0) { - fprintf(stderr, "Error:snd_pcm_hw_params_set_format %s\n", snd_strerror(rc)); + fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_format %s\n", snd_strerror(rc)); return; } @@ -101,7 +101,7 @@ static void alsa_init() rc=snd_pcm_hw_params_set_channels(handle, params, 2); if (rc < 0) { - fprintf(stderr, "Error:snd_pcm_hw_params_set_channels %s\n", snd_strerror(rc)); + fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_channels %s\n", snd_strerror(rc)); return; } @@ -110,7 +110,7 @@ static void alsa_init() rc=snd_pcm_hw_params_set_rate_near(handle, params, &val, &dir); if (rc < 0) { - fprintf(stderr, "Error:snd_pcm_hw_params_set_rate_near %s\n", snd_strerror(rc)); + fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_rate_near %s\n", snd_strerror(rc)); return; } @@ -119,26 +119,31 @@ static void alsa_init() rc=snd_pcm_hw_params_set_period_size_near(handle, params, &period_size, &dir); if (rc < 0) { - fprintf(stderr, "Error:snd_pcm_hw_params_set_buffer_size_near %s\n", snd_strerror(rc)); + fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_buffer_size_near %s\n", snd_strerror(rc)); return; } else + { printf("ALSA: period size set to %ld\n", period_size); + } + buffer_size = (44100 * 100 /* settings.omx.Audio_Latency */ / 1000 / period_size + 1) * period_size; rc=snd_pcm_hw_params_set_buffer_size_near(handle, params, &buffer_size); if (rc < 0) { - fprintf(stderr, "Error:snd_pcm_hw_params_set_buffer_size_near %s\n", snd_strerror(rc)); + fprintf(stderr, "ALSA: Error:snd_pcm_hw_params_set_buffer_size_near %s\n", snd_strerror(rc)); return; } else + { printf("ALSA: buffer size set to %ld\n", buffer_size); + } /* Write the parameters to the driver */ rc = snd_pcm_hw_params(handle, params); if (rc < 0) { - fprintf(stderr, "Unable to set hw parameters: %s\n", snd_strerror(rc)); + fprintf(stderr, "ALSA: Unable to set hw parameters: %s\n", snd_strerror(rc)); return; } } From 139ef22408679f255fdc107c313364c540936b3d Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Thu, 2 May 2019 19:02:34 +0200 Subject: [PATCH 53/73] AUDIO: compile fixes for coreaudio, dsound and libao --- core/oslib/audiobackend_coreaudio.cpp | 3 ++- core/oslib/audiobackend_directsound.cpp | 3 ++- core/oslib/audiobackend_libao.cpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/oslib/audiobackend_coreaudio.cpp b/core/oslib/audiobackend_coreaudio.cpp index dd04926ce..8e0e9b344 100644 --- a/core/oslib/audiobackend_coreaudio.cpp +++ b/core/oslib/audiobackend_coreaudio.cpp @@ -159,7 +159,8 @@ audiobackend_t audiobackend_coreaudio = { "Core Audio", // Name &coreaudio_init, &coreaudio_push, - &coreaudio_term + &coreaudio_term, + NULL }; static bool core = RegisterAudioBackend(&audiobackend_coreaudio); diff --git a/core/oslib/audiobackend_directsound.cpp b/core/oslib/audiobackend_directsound.cpp index d173e434b..f004bdfd2 100644 --- a/core/oslib/audiobackend_directsound.cpp +++ b/core/oslib/audiobackend_directsound.cpp @@ -185,7 +185,8 @@ audiobackend_t audiobackend_directsound = { "Microsoft DirectSound", // Name &directsound_init, &directsound_push, - &directsound_term + &directsound_term, + NULL }; static bool ds = RegisterAudioBackend(&audiobackend_directsound); diff --git a/core/oslib/audiobackend_libao.cpp b/core/oslib/audiobackend_libao.cpp index c235dca00..0a6a72e7d 100644 --- a/core/oslib/audiobackend_libao.cpp +++ b/core/oslib/audiobackend_libao.cpp @@ -43,7 +43,8 @@ audiobackend_t audiobackend_libao = { "libao", // Name &libao_init, &libao_push, - &libao_term + &libao_term, + NULL }; static bool ao = RegisterAudioBackend(&audiobackend_libao); From 99033e297c604934dece7265d0e952740d7453a8 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Thu, 2 May 2019 20:24:49 +0200 Subject: [PATCH 54/73] AUDIO: Implement integer and checkbox options I remove "text" as a possibility for the moment as we're currently not having **any** text option. --- core/oslib/audiostream.h | 4 ++-- core/rend/gui.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/core/oslib/audiostream.h b/core/oslib/audiostream.h index 37c1cbc43..408592b55 100644 --- a/core/oslib/audiostream.h +++ b/core/oslib/audiostream.h @@ -14,8 +14,8 @@ void UpdateBuff(u8* pos); typedef std::vector (*audio_option_callback_t)(); enum audio_option_type { - text = 0 -, integer = 1 + integer = 0 +, checkbox = 1 , list = 2 }; diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 0404b503a..b6f0b30aa 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -1099,7 +1099,20 @@ static void gui_display_settings() } value = (*cfg_entries)[options->cfg_name]; - if (options->type == list) + if (options->type == integer) + { + int val = stoi(value); + ImGui::SliderInt(options->caption.c_str(), &val, options->min_value, options->max_value); + (*cfg_entries)[options->cfg_name] = to_string(val); + } + else if (options->type == checkbox) + { + bool check = (value == "1"); + ImGui::Checkbox(options->caption.c_str(), &check); + std::string cur = check ? "1" : "0"; + (*cfg_entries)[options->cfg_name] = cur; + } + else if (options->type == list) { if (ImGui::BeginCombo(options->caption.c_str(), value.c_str(), ImGuiComboFlags_None)) { @@ -1120,6 +1133,9 @@ static void gui_display_settings() ImGui::EndCombo(); } } + else { + printf("Unknown option\n"); + } options++; } From c330cdd88e4d302adc99a887984fecc861df812b Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 6 May 2019 15:23:54 +0200 Subject: [PATCH 55/73] fix scissor test and vertical scaling when using the Y scaler Fixes missing bottom half-screen in Mr Driller (PAL, 60 Hz), Kaen Seibo, Mahjong Taikai II Special, Pon'n'Music 1 and 2 when in TV Composite and RGB. Fixes stretched screen in Cho - Hatsumei Boy Kanipan. --- core/rend/gl4/gles.cpp | 8 ++++++++ core/rend/gles/gles.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/core/rend/gl4/gles.cpp b/core/rend/gl4/gles.cpp index aa2da9c99..202d48b31 100644 --- a/core/rend/gl4/gles.cpp +++ b/core/rend/gl4/gles.cpp @@ -656,6 +656,8 @@ static bool RenderFrame() { scale_x=fb_scale_x; scale_y=fb_scale_y; + if (SCALER_CTL.interlace == 0) + scale_y *= SCALER_CTL.vscalefactor / 0x400; //work out scaling parameters ! //Pixel doubling is on VO, so it does not affect any pixel operations @@ -868,6 +870,12 @@ static bool RenderFrame() float min_y = pvrrc.fb_Y_CLIP.min / scale_y; if (!is_rtt) { + if (SCALER_CTL.interlace) + { + // Clipping is done after scaling/filtering so account for that if enabled + height *= SCALER_CTL.vscalefactor / 0x400; + min_y *= SCALER_CTL.vscalefactor / 0x400; + } if (settings.rend.Rotate90) { float t = width; diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index a2155f460..684f96e26 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -1651,6 +1651,8 @@ bool RenderFrame() { scale_x=fb_scale_x; scale_y=fb_scale_y; + if (SCALER_CTL.interlace == 0) + scale_y *= SCALER_CTL.vscalefactor / 0x400; //work out scaling parameters ! //Pixel doubling is on VO, so it does not affect any pixel operations @@ -1900,6 +1902,12 @@ bool RenderFrame() float min_y = pvrrc.fb_Y_CLIP.min / scale_y; if (!is_rtt) { + if (SCALER_CTL.interlace) + { + // Clipping is done after scaling/filtering so account for that if enabled + height *= SCALER_CTL.vscalefactor / 0x400; + min_y *= SCALER_CTL.vscalefactor / 0x400; + } if (settings.rend.Rotate90) { float t = width; From ed8bcd7329c46747585c0570d6a5609226a61476 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Wed, 8 May 2019 20:47:58 +0200 Subject: [PATCH 56/73] Add SDL2 audio backend. The backend supports 44.1KHz and 48KHz (with resamping). The resampler is not great, has some noise but no idea where it comes from. This enables the switch port, since using SDL2 is the quickest way to get audio working. TODO: Add support in the cmake, once cmake is fixed at master/HEAD. --- core/oslib/audiobackend_sdl2.cpp | 136 +++++++++++++++++++++++++++++++ shell/linux/Makefile | 6 ++ 2 files changed, 142 insertions(+) create mode 100644 core/oslib/audiobackend_sdl2.cpp diff --git a/core/oslib/audiobackend_sdl2.cpp b/core/oslib/audiobackend_sdl2.cpp new file mode 100644 index 000000000..39d2e8464 --- /dev/null +++ b/core/oslib/audiobackend_sdl2.cpp @@ -0,0 +1,136 @@ + +#if defined(USE_SDL_AUDIO) + +#include +#include "oslib/audiostream.h" +#include "stdclass.h" + +static SDL_AudioDeviceID audiodev; +static bool needs_resampling; +static cResetEvent read_wait; +static cMutex stream_mutex; +static struct { + uint32_t prevs; + uint32_t sample_buffer[2048]; +} audiobuf; +static unsigned sample_count = 0; + +// To easily access samples. +union Sample { int16_t s[2]; uint32_t l; }; + +static float InterpolateCatmull4pt3oX(float x0, float x1, float x2, float x3, float t) { + return 0.45 * ((2 * x1) + t * ((-x0 + x2) + t * ((2 * x0 - 5 * x1 + 4 * x2 - x3) + t * (-x0 + 3 * x1 - 3 * x2 + x3)))); +} + +static void sdl2_audiocb(void* userdata, Uint8* stream, int len) { + stream_mutex.Lock(); + // Wait until there's enough samples to feed the kraken + unsigned oslen = len / sizeof(uint32_t); + unsigned islen = needs_resampling ? oslen * 16 / 17 : oslen; + unsigned minlen = needs_resampling ? islen + 2 : islen; // Resampler looks ahead by 2 samples. + + if (sample_count < minlen) { + // No data, just output a bit of silence for the underrun + memset(stream, 0, len); + stream_mutex.Unlock(); + read_wait.Set(); + return; + } + + if (!needs_resampling) { + // Just copy bytes for this case. + memcpy(stream, &audiobuf.sample_buffer[0], len); + } + else { + // 44.1KHz to 48KHz (actually 46.86KHz) resampling + uint32_t *outbuf = (uint32_t*)stream; + const float ra = 1.0f / 17; + Sample *sbuf = (Sample*)&audiobuf.sample_buffer[0]; // [-1] stores the previous iteration last sample output + for (int i = 0; i < islen/16; i++) { + *outbuf++ = sbuf[i*16+ 0].l; // First sample stays at the same location. + for (int k = 1; k < 17; k++) { + Sample r; + // Note we access offset -1 on first iteration, as to access prevs + r.s[0] = InterpolateCatmull4pt3oX(sbuf[i*16+k-2].s[0], sbuf[i*16+k-1].s[0], sbuf[i*16+k].s[0], sbuf[i*16+k+1].s[0], 1 - ra*k); + r.s[1] = InterpolateCatmull4pt3oX(sbuf[i*16+k-2].s[1], sbuf[i*16+k-1].s[1], sbuf[i*16+k].s[1], sbuf[i*16+k+1].s[1], 1 - ra*k); + *outbuf++ = r.l; + } + } + audiobuf.prevs = audiobuf.sample_buffer[islen-1]; + } + + // Move samples in the buffer and consume them + memmove(&audiobuf.sample_buffer[0], &audiobuf.sample_buffer[islen], (sample_count-islen)*sizeof(uint32_t)); + sample_count -= islen; + + stream_mutex.Unlock(); + read_wait.Set(); +} + +static void sdl2_audio_init() { + if (!SDL_WasInit(SDL_INIT_AUDIO)) + SDL_InitSubSystem(SDL_INIT_AUDIO); + + // Support 44.1KHz (native) but also upsampling to 48KHz + SDL_AudioSpec wav_spec, out_spec; + memset(&wav_spec, 0, sizeof(wav_spec)); + wav_spec.freq = 44100; + wav_spec.format = AUDIO_S16; + wav_spec.channels = 2; + wav_spec.samples = 1024; // Must be power of two + wav_spec.callback = sdl2_audiocb; + + // Try 44.1KHz which should be faster since it's native. + audiodev = SDL_OpenAudioDevice(NULL, 0, &wav_spec, &out_spec, 0); + if (!audiodev) { + needs_resampling = true; + wav_spec.freq = 48000; + audiodev = SDL_OpenAudioDevice(NULL, 0, &wav_spec, &out_spec, 0); + verify(audiodev); + } +} + +static u32 sdl2_audio_push(void* frame, u32 samples, bool wait) { + // Unpause the device shall it be paused. + if (SDL_GetAudioDeviceStatus(audiodev) != SDL_AUDIO_PLAYING) + SDL_PauseAudioDevice(audiodev, 0); + + // If wait, then wait for the buffer to be smaller than a certain size. + stream_mutex.Lock(); + if (wait) { + while (sample_count + samples > sizeof(audiobuf.sample_buffer)/sizeof(audiobuf.sample_buffer[0])) { + stream_mutex.Unlock(); + read_wait.Wait(); + read_wait.Reset(); + stream_mutex.Lock(); + } + } + + // Copy as many samples as possible, drop any remaining (this should not happen usually) + unsigned free_samples = sizeof(audiobuf.sample_buffer) / sizeof(audiobuf.sample_buffer[0]) - sample_count; + unsigned tocopy = samples < free_samples ? samples : free_samples; + memcpy(&audiobuf.sample_buffer[sample_count], frame, tocopy * sizeof(uint32_t)); + sample_count += tocopy; + stream_mutex.Unlock(); + + return 1; +} + +static void sdl2_audio_term() { + // Stop audio playback. + SDL_PauseAudioDevice(audiodev, 1); + read_wait.Set(); +} + +audiobackend_t audiobackend_sdl2audio = { + "sdl2", // Slug + "Simple DirectMedia Layer 2 Audio", // Name + &sdl2_audio_init, + &sdl2_audio_push, + &sdl2_audio_term +}; + +static bool sdl2audiobe = RegisterAudioBackend(&audiobackend_sdl2audio); + +#endif + diff --git a/shell/linux/Makefile b/shell/linux/Makefile index 6af3aed05..b96a05891 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -6,6 +6,7 @@ FOR_LINUX :=1 WEBUI :=1 USE_OSS := 1 #USE_PULSEAUDIO := 1 +#USE_SDLAUDIO := 1 #USE_LIBAO := 1 USE_EVDEV := 1 USE_UDEV := 1 @@ -360,6 +361,11 @@ ifdef USE_PULSEAUDIO LIBS += `pkg-config --libs libpulse-simple` endif +ifdef USE_SDLAUDIO + CXXFLAGS += `sdl2-config --cflags` -D USE_SDL_AUDIO + LIBS += `sdl2-config --libs` +endif + ifdef USE_LIBAO CXXFLAGS += `pkg-config --cflags ao` -D USE_LIBAO LIBS += `pkg-config --libs ao` From 3cd9736fcaf32c0d81cd44f02cb30203275eed0e Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Wed, 8 May 2019 21:33:49 +0200 Subject: [PATCH 57/73] Ignore vscalefactor if < 1 fix black screen on some intel platforms --- core/rend/gl4/gles.cpp | 4 ++-- core/rend/gles/gles.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/rend/gl4/gles.cpp b/core/rend/gl4/gles.cpp index 202d48b31..4d3003569 100644 --- a/core/rend/gl4/gles.cpp +++ b/core/rend/gl4/gles.cpp @@ -656,7 +656,7 @@ static bool RenderFrame() { scale_x=fb_scale_x; scale_y=fb_scale_y; - if (SCALER_CTL.interlace == 0) + if (SCALER_CTL.interlace == 0 && SCALER_CTL.vscalefactor >= 0x400) scale_y *= SCALER_CTL.vscalefactor / 0x400; //work out scaling parameters ! @@ -870,7 +870,7 @@ static bool RenderFrame() float min_y = pvrrc.fb_Y_CLIP.min / scale_y; if (!is_rtt) { - if (SCALER_CTL.interlace) + if (SCALER_CTL.interlace && SCALER_CTL.vscalefactor >= 0x400) { // Clipping is done after scaling/filtering so account for that if enabled height *= SCALER_CTL.vscalefactor / 0x400; diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index 684f96e26..9e7c812a2 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -1651,7 +1651,7 @@ bool RenderFrame() { scale_x=fb_scale_x; scale_y=fb_scale_y; - if (SCALER_CTL.interlace == 0) + if (SCALER_CTL.interlace == 0 && SCALER_CTL.vscalefactor >= 0x400) scale_y *= SCALER_CTL.vscalefactor / 0x400; //work out scaling parameters ! @@ -1902,7 +1902,7 @@ bool RenderFrame() float min_y = pvrrc.fb_Y_CLIP.min / scale_y; if (!is_rtt) { - if (SCALER_CTL.interlace) + if (SCALER_CTL.interlace && SCALER_CTL.vscalefactor >= 0x400) { // Clipping is done after scaling/filtering so account for that if enabled height *= SCALER_CTL.vscalefactor / 0x400; From 0eb874ba1c973994eeab5da9f486e4c15def3e71 Mon Sep 17 00:00:00 2001 From: David GF Date: Wed, 8 May 2019 22:33:14 +0200 Subject: [PATCH 58/73] Adding ARM64 Linux target in Makefile --- shell/linux/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shell/linux/Makefile b/shell/linux/Makefile index 6af3aed05..58ba615fc 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -45,6 +45,7 @@ ifeq (,$(platform)) else ifeq ($(ARCH), $(filter $(ARCH), x86_64 AMD64 amd64)) platform = x64 else ifneq (,$(findstring aarch64,$(ARCH))) + platform = arm64 HARDWARE = $(shell grep Hardware /proc/cpuinfo) ifneq (,$(findstring Vero4K,$(HARDWARE))) platform = vero4k @@ -122,6 +123,15 @@ else ifneq (,$(findstring x64,$(platform))) HAS_SOFTREND := 1 endif +# Generic 64 bit ARM (armv8) Linux +else ifneq (,$(findstring arm64,$(platform))) + NOT_ARM := 1 + USE_X11 := 1 + ARM64_REC := 1 + ISARM64 := 1 + CFLAGS += -D TARGET_LINUX_ARMv8 -D TARGET_NO_AREC -fno-builtin-sqrtf + CXXFLAGS += -fexceptions + # Generic 32 bit ARMhf (a.k.a. ARMv7h) else ifneq (,$(findstring armv7h,$(platform))) MFLAGS += -marm -mfloat-abi=hard -march=armv7-a -funroll-loops From 5ba56627a9c37db320b3743f2cc0143e9ed0e0f7 Mon Sep 17 00:00:00 2001 From: David GF Date: Wed, 8 May 2019 23:53:56 +0200 Subject: [PATCH 59/73] Optimize rec-ARM64 by emitting less instructions on loads. Fast load uses 3 or 4 insts, whereas slow load takes 2+. On A57 measured ~3% perf, which is expected for an OOO CPU, hopefully perf will be much better on A53 and other in-order CPUs. --- core/rec-ARM64/rec_arm64.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/rec-ARM64/rec_arm64.cpp b/core/rec-ARM64/rec_arm64.cpp index b30720796..2a9108349 100644 --- a/core/rec-ARM64/rec_arm64.cpp +++ b/core/rec-ARM64/rec_arm64.cpp @@ -1420,9 +1420,12 @@ private: std::vector call_fregs; Arm64RegAlloc regalloc; RuntimeBlockInfo* block; + const int write_memory_rewrite_size = 3; // same size (fast write) for any size: add, bfc, str + #ifdef EXPLODE_SPANS const int read_memory_rewrite_size = 6; // worst case for u64: add, bfc, ldr, fmov, lsr, fmov - // FIXME rewrite size per read/write size? - const int write_memory_rewrite_size = 3; + #else + const int read_memory_rewrite_size = 4; // worst case for u64: add, bfc, ldr, str + #endif }; static Arm64Assembler* compiler; From eb725f9e66da28568d96e9649aa9ba30fa4d5d4c Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 10 May 2019 11:15:44 +0200 Subject: [PATCH 60/73] x11: fix fallback to gl 3.0. fix crash when switching renderer. Fallback to GL 3.1 when GL 4.3 isn't available was broken. Fallback to GL 3.0 instead of 3.1. Fix crash when switching renderer (per-pixel, per-triangle) --- core/hw/pvr/Renderer_if.cpp | 18 ++++++++++-------- core/linux-dist/x11.cpp | 13 ++++++++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/core/hw/pvr/Renderer_if.cpp b/core/hw/pvr/Renderer_if.cpp index 0a9c5b16b..71c954e34 100644 --- a/core/hw/pvr/Renderer_if.cpp +++ b/core/hw/pvr/Renderer_if.cpp @@ -98,6 +98,7 @@ TA_context* _pvrrc; void SetREP(TA_context* cntx); void killtex(); bool render_output_framebuffer(); +static void rend_create_renderer(); void dump_frame(const char* file, TA_context* ctx, u8* vram, u8* vram_ref = NULL) { FILE* fw = fopen(file, "wb"); @@ -266,6 +267,13 @@ bool rend_frame(TA_context* ctx, bool draw_osd) { bool rend_single_frame() { + if (renderer_changed) + { + renderer_changed = false; + rend_term_renderer(); + rend_create_renderer(); + rend_init_renderer(); + } //wait render start only if no frame pending do { @@ -362,6 +370,7 @@ void rend_init_renderer() } printf("Selected renderer initialization failed. Falling back to default renderer.\n"); renderer = fallback_renderer; + fallback_renderer = NULL; // avoid double-free } } @@ -377,7 +386,6 @@ void rend_term_renderer() delete fallback_renderer; fallback_renderer = NULL; } - tactx_Term(); } void* rend_thread(void* p) @@ -391,13 +399,6 @@ void* rend_thread(void* p) { if (rend_single_frame()) renderer->Present(); - if (renderer_changed) - { - renderer_changed = false; - rend_term_renderer(); - rend_create_renderer(); - rend_init_renderer(); - } } rend_term_renderer(); @@ -538,6 +539,7 @@ void rend_end_render() void rend_stop_renderer() { renderer_enabled = false; + tactx_Term(); } void rend_vblank() diff --git a/core/linux-dist/x11.cpp b/core/linux-dist/x11.cpp index aa71bdbdf..e053097be 100644 --- a/core/linux-dist/x11.cpp +++ b/core/linux-dist/x11.cpp @@ -361,6 +361,11 @@ void input_x11_init() printf("X11 Keyboard input disabled by config.\n"); } +static int x11_error_handler(Display *, XErrorEvent *) +{ + return 0; +} + void x11_window_create() { if (cfgLoadInt("pvr", "nox11", 0) == 0) @@ -519,20 +524,22 @@ void x11_window_create() GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, None }; + int (*old_handler)(Display *, XErrorEvent *) = XSetErrorHandler(&x11_error_handler); x11_glc = glXCreateContextAttribsARB(x11Display, bestFbc, 0, True, context_attribs); if (!x11_glc) { printf("Open GL 4.3 not supported\n"); - // Try GL 3.1 + // Try GL 3.0 context_attribs[1] = 3; - context_attribs[3] = 1; + context_attribs[3] = 0; x11_glc = glXCreateContextAttribsARB(x11Display, bestFbc, 0, True, context_attribs); if (!x11_glc) { - die("Open GL 3.1 not supported\n"); + die("Open GL 3.0 not supported\n"); } } + XSetErrorHandler(old_handler); XSync(x11Display, False); #endif From be1ecbaa8ba9124807dda1ed21b1a9cfa38c4a1e Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Fri, 10 May 2019 18:57:28 +0200 Subject: [PATCH 61/73] Fix TARGET_NO_NVMEM and deprecate TARGET_NO_EXCEPTIONS Linked them both toghether since you can't really define one and not the other (plus Linux honors one windows the other in some cases). More refactoring on this area to follow. --- core/hw/mem/_vmem.cpp | 2 +- core/hw/sh4/dyna/blockmanager.cpp | 4 ++-- core/linux/common.cpp | 17 ++++++++--------- core/linux/context.cpp | 4 ++-- shell/cmake/config.cmake | 4 ++-- shell/emscripten/Makefile | 2 +- shell/nacl/Makefile | 4 ++-- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/core/hw/mem/_vmem.cpp b/core/hw/mem/_vmem.cpp index 2c02197c5..e621fa948 100644 --- a/core/hw/mem/_vmem.cpp +++ b/core/hw/mem/_vmem.cpp @@ -440,7 +440,7 @@ void _vmem_bm_reset() { if (!virt_ram_base) #endif { - bm_vmem_pagefill((void**)p_sh4rcb->fpcb, FPCB_SIZE); + bm_vmem_pagefill((void**)p_sh4rcb->fpcb, sizeof(p_sh4rcb->fpcb)); } } diff --git a/core/hw/sh4/dyna/blockmanager.cpp b/core/hw/sh4/dyna/blockmanager.cpp index e64cd0d60..0994c3469 100644 --- a/core/hw/sh4/dyna/blockmanager.cpp +++ b/core/hw/sh4/dyna/blockmanager.cpp @@ -339,9 +339,9 @@ void bm_Rebuild() rebuild_counter=30; } -void bm_vmem_pagefill(void** ptr,u32 PAGE_SZ) +void bm_vmem_pagefill(void** ptr, u32 size_bytes) { - for (size_t i=0; i void VArray2::LockRegion(u32 offset,u32 size) { - #if !defined(TARGET_NO_EXCEPTIONS) + #if !defined(TARGET_NO_NVMEM) u32 inpage=offset & PAGE_MASK; u32 rv=mprotect (data+offset-inpage, size+inpage, PROT_READ ); if (rv!=0) @@ -185,7 +184,7 @@ void print_mem_addr() void VArray2::UnLockRegion(u32 offset,u32 size) { - #if !defined(TARGET_NO_EXCEPTIONS) + #if !defined(TARGET_NO_NVMEM) u32 inpage=offset & PAGE_MASK; u32 rv=mprotect (data+offset-inpage, size+inpage, PROT_READ | PROT_WRITE); if (rv!=0) diff --git a/core/linux/context.cpp b/core/linux/context.cpp index 7c317c401..9884ad426 100644 --- a/core/linux/context.cpp +++ b/core/linux/context.cpp @@ -8,7 +8,7 @@ #define __USE_GNU 1 #endif - #if !defined(TARGET_NO_EXCEPTIONS) + #if !defined(TARGET_NO_NVMEM) #include #endif #endif @@ -29,7 +29,7 @@ void bicopy(Ta& rei, Tb& seg, bool to_segfault) { void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_segfault) { -#if !defined(TARGET_NO_EXCEPTIONS) +#if !defined(TARGET_NO_NVMEM) #if HOST_CPU == CPU_ARM #if defined(__FreeBSD__) bicopy(reictx->pc, MCTX(.__gregs[_REG_PC]), to_segfault); diff --git a/shell/cmake/config.cmake b/shell/cmake/config.cmake index d1dfd59e4..056b7e74a 100644 --- a/shell/cmake/config.cmake +++ b/shell/cmake/config.cmake @@ -343,7 +343,7 @@ if (TARGET_NSW) # -DCMAKE_TOOLCHAIN_FILE=./cmake/devkitA64.cmake -DTARGET_NSW=ON message("HOST_OS ${HOST_OS}") add_definitions(-D__SWITCH__ -DGLES -DMESA_EGL_NO_X11_HEADERS) - add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_EXCEPTIONS -DTARGET_NO_NIXPROF) + add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_NVMEM -DTARGET_NO_NIXPROF) add_definitions(-DTARGET_NO_COREIO_HTTP -DTARGET_NO_WEBUI -UTARGET_SOFTREND) add_definitions(-D_GLIBCXX_USE_C99_MATH_TR1 -D_LDBL_EQ_DBL) @@ -355,7 +355,7 @@ if (TARGET_PS4) # -DCMAKE_TOOLCHAIN_FILE=./cmake/{ps4sdk,clang_scei}.cmake -DTAR add_definitions(-DPS4 -DTARGET_PS4 -DTARGET_BSD -D__ORBIS__ -DGLES -DMESA_EGL_NO_X11_HEADERS) ## last needed for __unix__ on eglplatform.h - add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_EXCEPTIONS -DTARGET_NO_NIXPROF) + add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_NVMEM -DTARGET_NO_NIXPROF) add_definitions(-DTARGET_NO_COREIO_HTTP -DTARGET_NO_WEBUI -UTARGET_SOFTREND) diff --git a/shell/emscripten/Makefile b/shell/emscripten/Makefile index 6f1054198..1c74e19b6 100644 --- a/shell/emscripten/Makefile +++ b/shell/emscripten/Makefile @@ -26,7 +26,7 @@ LDFLAGS := -Wl,-Map,$(notdir $@).map,--gc-sections -Wl,-O3 -Wl,--sort-common CXXONLYFLAGS := -std=c++11 -CXXFLAGS := -O3 -D GLES -D RELEASE -c -D TARGET_EMSCRIPTEN -D TARGET_NO_REC -D TARGET_NO_NVMEM -D TARGET_NO_WEBUI -D TARGET_NO_THREADS -D TARGET_BOUNDED_EXECUTION -D TARGET_NO_EXCEPTIONS -D TARGET_NO_COREIO_HTTP +CXXFLAGS := -O3 -D GLES -D RELEASE -c -D TARGET_EMSCRIPTEN -D TARGET_NO_REC -D TARGET_NO_NVMEM -D TARGET_NO_WEBUI -D TARGET_NO_THREADS -D TARGET_BOUNDED_EXECUTION -D TARGET_NO_COREIO_HTTP CXXFLAGS += -fno-strict-aliasing CXXFLAGS += -ffast-math diff --git a/shell/nacl/Makefile b/shell/nacl/Makefile index 733a7d538..e0d03834e 100644 --- a/shell/nacl/Makefile +++ b/shell/nacl/Makefile @@ -23,7 +23,7 @@ CFLAGS = -Wno-error -Wno-ignored-attributes CFLAGS += -O3 -fno-strict-aliasing -ffast-math CFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps CFLAGS += -D RELEASE -D TARGET_NO_JIT -D TARGET_NACL32 -DGLES -CFLAGS += -D TARGET_NO_EXCEPTIONS -D TARGET_NO_NVMEM -D TARGET_NO_WEBUI -D TARGET_NO_COREIO_HTTP +CFLAGS += -D TARGET_NO_NVMEM -D TARGET_NO_WEBUI -D TARGET_NO_COREIO_HTTP SOURCES = $(RZDCY_FILES) ../../core/nacl/nacl.cpp @@ -49,4 +49,4 @@ endif SHELL = sh -$(eval $(call NMF_RULE,$(TARGET),)) \ No newline at end of file +$(eval $(call NMF_RULE,$(TARGET),)) From 45b0e79f15c07b22566f5a96814ac8b3896d9f74 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Fri, 10 May 2019 19:20:19 +0200 Subject: [PATCH 62/73] Enable modem support in Android builds, regresion of PR #1571 This affects bug #1591 --- shell/android-studio/reicast/src/main/jni/Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/android-studio/reicast/src/main/jni/Android.mk b/shell/android-studio/reicast/src/main/jni/Android.mk index 9bb894c11..0eb55d90a 100644 --- a/shell/android-studio/reicast/src/main/jni/Android.mk +++ b/shell/android-studio/reicast/src/main/jni/Android.mk @@ -22,6 +22,7 @@ WEBUI := 1 USE_GLES := 1 CHD5_LZMA := 1 CHD5_FLAC := 1 +USE_MODEM := 1 ifneq ($(TARGET_ARCH_ABI),armeabi-v7a) NOT_ARM := 1 From 2389903a30885367b3245443e7175fada01ef028 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Fri, 10 May 2019 19:38:45 +0200 Subject: [PATCH 63/73] Add dummy serialization for non-modem builds (right now only Win) --- core/serialize.cpp | 85 +++++++++------------------------------------- 1 file changed, 16 insertions(+), 69 deletions(-) diff --git a/core/serialize.cpp b/core/serialize.cpp index 1d7fec35b..f9a40da7f 100644 --- a/core/serialize.cpp +++ b/core/serialize.cpp @@ -1050,18 +1050,19 @@ bool dc_serialize(void **data, unsigned int *total_size) REICAST_S(sch_list[modem_sched].tag) ; REICAST_S(sch_list[modem_sched].start) ; REICAST_S(sch_list[modem_sched].end) ; + #else + int modem_dummy = 0; + REICAST_S(modem_dummy); + REICAST_S(modem_dummy); + REICAST_S(modem_dummy); #endif REICAST_S(SCIF_SCFSR2); REICAST_S(SCIF_SCFRDR2); REICAST_S(SCIF_SCFDR2); - REICAST_S(BSC_PDTRA); - - - REICAST_SA(tmu_shift,3); REICAST_SA(tmu_mask,3); REICAST_SA(tmu_mask64,3); @@ -1069,14 +1070,8 @@ bool dc_serialize(void **data, unsigned int *total_size) REICAST_SA(tmu_ch_base,3); REICAST_SA(tmu_ch_base64,3); - - - REICAST_SA(CCN_QACR_TR,2); - - - REICAST_SA(UTLB,64); REICAST_SA(ITLB,4); #if defined(NO_MMU) @@ -1086,8 +1081,6 @@ bool dc_serialize(void **data, unsigned int *total_size) REICAST_S(mmu_error_TT); #endif - - REICAST_S(NullDriveDiscType); REICAST_SA(q_subchannel,96); @@ -1129,22 +1122,16 @@ bool dc_serialize(void **data, unsigned int *total_size) REICAST_S(div_som_reg2); REICAST_S(div_som_reg3); - - REICAST_S(LastAddr); REICAST_S(LastAddr_min); REICAST_SA(block_hash,1024); - REICAST_SA(RegisterWrite,sh4_reg_count); REICAST_SA(RegisterRead,sh4_reg_count); REICAST_S(fallback_blocks); REICAST_S(total_blocks); REICAST_S(REMOVED_OPS); - - - REICAST_SA(kcode,4); REICAST_SA(rt,4); REICAST_SA(lt,4); @@ -1245,12 +1232,7 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) //this is one-time init, no updates - don't need to serialize //extern _vmem_handler area0_handler; - - - - REICAST_USA(reply_11,16) ; - - + REICAST_USA(reply_11,16); REICAST_US(sns_asc); REICAST_US(sns_ascq); @@ -1364,8 +1346,6 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_USA(mem_b.data, mem_b.size); - - REICAST_US(IRLPriority); REICAST_USA(InterruptEnvId,32); REICAST_USA(InterruptBit,32); @@ -1374,9 +1354,6 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(interrupt_vmask); REICAST_US(decoded_srimask); - - - REICAST_US(i) ; if ( i == 0 ) do_sqw_nommu = &do_sqw_nommu_area_3 ; @@ -1401,9 +1378,6 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(old_rm); REICAST_US(old_dn); - - - REICAST_US(sh4_sched_ffb); REICAST_US(sh4_sched_intr); @@ -1452,18 +1426,19 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(sch_list[modem_sched].tag) ; REICAST_US(sch_list[modem_sched].start) ; REICAST_US(sch_list[modem_sched].end) ; + #else + int modem_dummy; + REICAST_US(modem_dummy); + REICAST_US(modem_dummy); + REICAST_US(modem_dummy); #endif REICAST_US(SCIF_SCFSR2); REICAST_US(SCIF_SCFRDR2); REICAST_US(SCIF_SCFDR2); - REICAST_US(BSC_PDTRA); - - - REICAST_USA(tmu_shift,3); REICAST_USA(tmu_mask,3); REICAST_USA(tmu_mask64,3); @@ -1471,14 +1446,8 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_USA(tmu_ch_base,3); REICAST_USA(tmu_ch_base64,3); - - - REICAST_USA(CCN_QACR_TR,2); - - - REICAST_USA(UTLB,64); REICAST_USA(ITLB,4); #if defined(NO_MMU) @@ -1488,9 +1457,6 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(mmu_error_TT); #endif - - - REICAST_US(NullDriveDiscType); REICAST_USA(q_subchannel,96); @@ -1545,9 +1511,6 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(div_som_reg2); REICAST_US(div_som_reg3); - - - //REICAST_USA(CodeCache,CODE_SIZE) ; //REICAST_USA(SH4_TCB,CODE_SIZE+4096); REICAST_US(LastAddr); @@ -1611,7 +1574,6 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_US(timers[i].m_step); } - REICAST_USA(aica_ram.data,aica_ram.size) ; REICAST_US(VREG); REICAST_US(ARMRST); @@ -1619,8 +1581,6 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_USA(aica_reg,0x8000); - - REICAST_USA(volume_lut,16); REICAST_USA(tl_lut,256 + 768); REICAST_USA(AEG_ATT_SPS,64); @@ -1635,14 +1595,11 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_USA(mxlr,64); REICAST_US(samples_gen); - register_unserialize(sb_regs, data, total_size) ; REICAST_US(SB_ISTNRM); REICAST_US(SB_FFST_rc); REICAST_US(SB_FFST); - - //this is one-time init, no updates - don't need to serialize //extern RomChip sys_rom; REICAST_US(sys_nvmem.size); @@ -1754,8 +1711,6 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_USA(mem_b.data, mem_b.size); - - REICAST_US(IRLPriority); REICAST_USA(InterruptEnvId,32); REICAST_USA(InterruptBit,32); @@ -1764,9 +1719,6 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_US(interrupt_vmask); REICAST_US(decoded_srimask); - - - REICAST_US(i) ; if ( i == 0 ) do_sqw_nommu = &do_sqw_nommu_area_3 ; @@ -1842,6 +1794,11 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_US(sch_list[modem_sched].tag) ; REICAST_US(sch_list[modem_sched].start) ; REICAST_US(sch_list[modem_sched].end) ; + #else + int modem_dummy; + REICAST_US(modem_dummy); + REICAST_US(modem_dummy); + REICAST_US(modem_dummy); #endif REICAST_US(SCIF_SCFSR2); @@ -1879,8 +1836,6 @@ bool dc_unserialize(void **data, unsigned int *total_size) #endif - - REICAST_US(NullDriveDiscType); REICAST_USA(q_subchannel,96); @@ -1896,7 +1851,6 @@ bool dc_unserialize(void **data, unsigned int *total_size) // REICAST_US(i); // VRAM_MASK - REICAST_US(naomi_updates); REICAST_US(i); // BoardID REICAST_US(GSerialBuffer); @@ -1935,25 +1889,18 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_US(div_som_reg2); REICAST_US(div_som_reg3); - - - //REICAST_USA(CodeCache,CODE_SIZE) ; //REICAST_USA(SH4_TCB,CODE_SIZE+4096); REICAST_US(LastAddr); REICAST_US(LastAddr_min); REICAST_USA(block_hash,1024); - REICAST_USA(RegisterWrite,sh4_reg_count); REICAST_USA(RegisterRead,sh4_reg_count); REICAST_US(fallback_blocks); REICAST_US(total_blocks); REICAST_US(REMOVED_OPS); - - - REICAST_USA(kcode,4); REICAST_USA(rt,4); REICAST_USA(lt,4); From c0f21b7551bcb686840e53ed4c1262cf341cee6b Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Fri, 10 May 2019 19:41:36 +0200 Subject: [PATCH 64/73] Re-enable modem in Apple builds too. --- shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj index a12ad753f..cff1dafd5 100644 --- a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj +++ b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj @@ -2546,6 +2546,7 @@ TARGET_NO_AREC, XBYAK_NO_OP_NAMES, TARGET_NO_OPENMP, + ENABLE_MODEM, CHD5_LZMA, _7ZIP_ST, CHD5_FLAC, @@ -2602,6 +2603,7 @@ TARGET_NO_AREC, XBYAK_NO_OP_NAMES, TARGET_NO_OPENMP, + ENABLE_MODEM, CHD5_LZMA, _7ZIP_ST, CHD5_FLAC, From 08285cf49cfbcb252bc244d3f6909db691c43aed Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 11 May 2019 13:37:13 +0200 Subject: [PATCH 65/73] Hack-fix the x86 JIT so that it builds. I guess that's why Win32 fails too --- core/rec-x86/rec_x86_driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/rec-x86/rec_x86_driver.cpp b/core/rec-x86/rec_x86_driver.cpp index 1d19a46fa..727cf4eee 100644 --- a/core/rec-x86/rec_x86_driver.cpp +++ b/core/rec-x86/rec_x86_driver.cpp @@ -326,8 +326,8 @@ void ngen_Compile(RuntimeBlockInfo* block, SmcCheckEnum smc_checks, bool reset, if (prof.enable) { - if (force_checks) - x86e->Emit(op_add32,&prof.counters.blkrun.force_check,1); + //if (force_checks) + // x86e->Emit(op_add32,&prof.counters.blkrun.force_check,1); x86e->Emit(op_add32,&prof.counters.blkrun.cycles[block->guest_cycles],1); } From b74db6ef53cbbc3870453a6487d0b5854136bf06 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 11 May 2019 22:09:52 +0200 Subject: [PATCH 66/73] Moving vmem to separate files with a proper interface. Works so far for Linux and Android, need to do some testing on Windows. --- core/hw/aica/aica_if.cpp | 2 +- core/hw/aica/aica_if.h | 2 +- core/hw/mem/_vmem.cpp | 469 +++++++------------------------------- core/hw/mem/_vmem.h | 29 ++- core/hw/pvr/pvr_mem.h | 4 +- core/hw/sh4/sh4_mem.cpp | 2 +- core/hw/sh4/sh4_mem.h | 2 +- core/linux/common.cpp | 72 +----- core/linux/context.cpp | 4 +- core/linux/posix_vmem.cpp | 177 ++++++++++++++ core/rend/TexCache.cpp | 5 +- core/serialize.cpp | 6 +- core/stdclass.h | 42 ++-- core/windows/win_vmem.cpp | 96 ++++++++ core/windows/winmain.cpp | 18 -- shell/cmake/config.cmake | 4 +- shell/emscripten/Makefile | 2 +- shell/nacl/Makefile | 2 +- 18 files changed, 432 insertions(+), 506 deletions(-) create mode 100644 core/linux/posix_vmem.cpp create mode 100644 core/windows/win_vmem.cpp diff --git a/core/hw/aica/aica_if.cpp b/core/hw/aica/aica_if.cpp index 9ba65c0a7..d562a0de1 100644 --- a/core/hw/aica/aica_if.cpp +++ b/core/hw/aica/aica_if.cpp @@ -13,7 +13,7 @@ #include -VArray2 aica_ram; +VLockedMemory aica_ram; u32 VREG;//video reg =P u32 ARMRST;//arm reset reg u32 rtc_EN=0; diff --git a/core/hw/aica/aica_if.h b/core/hw/aica/aica_if.h index 8c58b5326..13ee6fd97 100644 --- a/core/hw/aica/aica_if.h +++ b/core/hw/aica/aica_if.h @@ -2,7 +2,7 @@ #include "types.h" extern u32 VREG; -extern VArray2 aica_ram; +extern VLockedMemory aica_ram; extern u32 RealTimeClock; u32 ReadMem_aica_rtc(u32 addr,u32 sz); void WriteMem_aica_rtc(u32 addr,u32 data,u32 sz); diff --git a/core/hw/mem/_vmem.cpp b/core/hw/mem/_vmem.cpp index e621fa948..9a297330c 100644 --- a/core/hw/mem/_vmem.cpp +++ b/core/hw/mem/_vmem.cpp @@ -21,7 +21,6 @@ _vmem_WriteMem32FP* _vmem_WF32[HANDLER_COUNT]; //upper 8b of the address void* _vmem_MemInfo_ptr[0x100]; - void _vmem_get_ptrs(u32 sz,bool write,void*** vmap,void*** func) { *vmap=_vmem_MemInfo_ptr; @@ -385,10 +384,7 @@ void _vmem_reset() verify(_vmem_register_handler(0,0,0,0,0,0)==0); } -void _vmem_term() -{ - -} +void _vmem_term() {} #include "hw/pvr/pvr_mem.h" #include "hw/sh4/sh4_mem.h" @@ -409,414 +405,119 @@ void* malloc_pages(size_t size) { #endif } -bool _vmem_reserve_nonvmem() -{ - virt_ram_base = 0; - - p_sh4rcb=(Sh4RCB*)malloc_pages(sizeof(Sh4RCB)); - - mem_b.size=RAM_SIZE; - mem_b.data=(u8*)malloc_pages(RAM_SIZE); - - vram.size=VRAM_SIZE; - vram.data=(u8*)malloc_pages(VRAM_SIZE); - - aica_ram.size=ARAM_SIZE; - aica_ram.data=(u8*)malloc_pages(ARAM_SIZE); - - return true; -} - -void _vmem_bm_reset_nvmem(); - +// Resets the FPCB table (by either clearing it to the default val +// or by flushing it and making it fault on access again. void _vmem_bm_reset() { - if (virt_ram_base) { - #if !defined(TARGET_NO_NVMEM) - _vmem_bm_reset_nvmem(); - #endif - } - -#ifndef TARGET_IPHONE - if (!virt_ram_base) -#endif - { + // If we allocated it via vmem: + if (virt_ram_base) + vmem_platform_reset_mem(p_sh4rcb->fpcb, sizeof(p_sh4rcb->fpcb)); + else + // We allocated it via a regular malloc/new/whatever on the heap bm_vmem_pagefill((void**)p_sh4rcb->fpcb, sizeof(p_sh4rcb->fpcb)); - } } -static void _vmem_release_nonvmem() -{ - free(p_sh4rcb); - free(vram.data); - free(aica_ram.data); - free(mem_b.data); -} +// This gets called whenever there is a pagefault, it is possible that it lands +// on the fpcb memory range, which is allocated on miss. Returning true tells the +// fault handler this was us, and that the page is resolved and can continue the execution. +bool BM_LockedWrite(u8* address) { + if (!virt_ram_base) + return false; // No vmem, therefore not us who caused this. -#if !defined(TARGET_NO_NVMEM) + uintptr_t ptrint = (uintptr_t)address; + uintptr_t start = (uintptr_t)p_sh4rcb->fpcb; + uintptr_t end = start + sizeof(p_sh4rcb->fpcb); -#define MAP_RAM_START_OFFSET 0 -#define MAP_VRAM_START_OFFSET (MAP_RAM_START_OFFSET+RAM_SIZE) -#define MAP_ARAM_START_OFFSET (MAP_VRAM_START_OFFSET+VRAM_SIZE) - -#if HOST_OS==OS_WINDOWS -#include -HANDLE mem_handle; - -void* _nvmem_map_buffer(u32 dst,u32 addrsz,u32 offset,u32 size, bool w) -{ - void* ptr; - void* rv; - - u32 map_times=addrsz/size; - verify((addrsz%size)==0); - verify(map_times>=1); - - rv= MapViewOfFileEx(mem_handle,FILE_MAP_READ | (w?FILE_MAP_WRITE:0),0,offset,size,&virt_ram_base[dst]); - if (!rv) - return 0; - - for (u32 i=1;i - #include - #include - #include - #include - #include - -#ifndef MAP_NOSYNC -#define MAP_NOSYNC 0 //missing from linux :/ -- could be the cause of android slowness ? -#endif - -#ifdef _ANDROID -#include - -#ifndef ASHMEM_DEVICE -#define ASHMEM_DEVICE "/dev/ashmem" -#endif -int ashmem_create_region(const char *name, size_t size) -{ - int fd, ret; - - fd = open(ASHMEM_DEVICE, O_RDWR); - if (fd < 0) - return fd; - - if (name) { - char buf[ASHMEM_NAME_LEN]; - - strlcpy(buf, name, sizeof(buf)); - ret = ioctl(fd, ASHMEM_SET_NAME, buf); - if (ret < 0) - goto error; - } - - ret = ioctl(fd, ASHMEM_SET_SIZE, size); - if (ret < 0) - goto error; - - return fd; - -error: - close(fd); - return ret; -} -#endif - - int fd; - void* _nvmem_unused_buffer(u32 start,u32 end) - { - void* ptr=mmap(&virt_ram_base[start], end-start, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); - if (MAP_FAILED==ptr) - return 0; - return ptr; - } - - - void* _nvmem_map_buffer(u32 dst,u32 addrsz,u32 offset,u32 size, bool w) - { - void* ptr; - void* rv; - - printf("MAP %08X w/ %d\n",dst,offset); - u32 map_times=addrsz/size; - verify((addrsz%size)==0); - verify(map_times>=1); - u32 prot=PROT_READ|(w?PROT_WRITE:0); - rv= mmap(&virt_ram_base[dst], size, prot, MAP_SHARED | MAP_NOSYNC | MAP_FIXED, fd, offset); - if (MAP_FAILED==rv || rv!=(void*)&virt_ram_base[dst] || (mprotect(rv,size,prot)!=0)) - { - printf("MAP1 failed %d\n",errno); - return 0; - } - - for (u32 i=1;i slow and stuttery - { - fd = open("/data/data/com.reicast.emulator/files/dcnzorz_mem",O_CREAT|O_RDWR|O_TRUNC,S_IRWXU|S_IRWXG|S_IRWXO); - unlink("/data/data/com.reicast.emulator/files/dcnzorz_mem"); - } -#endif - - - - u32 sz = 512*1024*1024 + sizeof(Sh4RCB) + ARAM_SIZE_MAX + 0x10000; - void* rv=mmap(0, sz, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); - verify(rv != NULL); - munmap(rv,sz); - return (u8*)rv + 0x10000 - unat(rv)%0x10000;//align to 64 KB (Needed for linaro mmap not to extend to next region) - } -#endif - -#define map_buffer(dsts,dste,offset,sz,w) {ptr=_nvmem_map_buffer(dsts,dste-dsts,offset,sz,w);if (!ptr) return false;} -#define unused_buffer(start,end) {ptr=_nvmem_unused_buffer(start,end);if (!ptr) return false;} - -u32 pagecnt; -void _vmem_bm_reset_nvmem() -{ - #if defined(TARGET_NO_NVMEM) - return; - #endif - - #ifdef TARGET_IPHONE - //On iOS & nacl we allways allocate all of the mapping table - mprotect(p_sh4rcb, sizeof(p_sh4rcb->fpcb), PROT_READ | PROT_WRITE); - return; - #endif - pagecnt=0; - -#if HOST_OS==OS_WINDOWS - VirtualFree(p_sh4rcb,sizeof(p_sh4rcb->fpcb),MEM_DECOMMIT); -#else - mprotect(p_sh4rcb, sizeof(p_sh4rcb->fpcb), PROT_NONE); - madvise(p_sh4rcb,sizeof(p_sh4rcb->fpcb),MADV_DONTNEED); - #ifdef MADV_REMOVE - madvise(p_sh4rcb,sizeof(p_sh4rcb->fpcb),MADV_REMOVE); - #else - //OSX, IOS - madvise(p_sh4rcb,sizeof(p_sh4rcb->fpcb),MADV_FREE); - #endif -#endif - - printf("Freeing fpcb\n"); -} - -bool BM_LockedWrite(u8* address) -{ - if (!_nvmem_enabled()) - return false; - -#if FEAT_SHREC != DYNAREC_NONE - u32 addr=address-(u8*)p_sh4rcb->fpcb; - - address=(u8*)p_sh4rcb->fpcb+ (addr&~PAGE_MASK); - - if (addrfpcb)) - { - //printf("Allocated %d PAGES [%08X]\n",++pagecnt,addr); - -#if HOST_OS==OS_WINDOWS - verify(VirtualAlloc(address,PAGE_SIZE,MEM_COMMIT,PAGE_READWRITE)); -#else - mprotect (address, PAGE_SIZE, PROT_READ | PROT_WRITE); -#endif - - bm_vmem_pagefill((void**)address,PAGE_SIZE); - + if (ptrint >= start && ptrint < end) { + // Alloc the page then and initialize it to default values + void *aligned_addr = (void*)(ptrint & (~PAGE_MASK)); + vmem_platform_ondemand_page(aligned_addr, PAGE_SIZE); + bm_vmem_pagefill((void**)aligned_addr, PAGE_SIZE); return true; } -#else -die("BM_LockedWrite and NO REC"); -#endif return false; } -bool _vmem_reserve() -{ - void* ptr=0; - +bool _vmem_reserve() { + // TODO: Static assert? verify((sizeof(Sh4RCB)%PAGE_SIZE)==0); - if (settings.dynarec.disable_nvmem) - return _vmem_reserve_nonvmem(); + VMemType vmemstatus = MemTypeError; - virt_ram_base=(u8*)_nvmem_alloc_mem(); + // Use vmem only if settings mandate so, and if we have proper exception handlers. + #ifndef TARGET_NO_EXCEPTIONS + if (!settings.dynarec.disable_nvmem) + vmemstatus = vmem_platform_init((void**)&virt_ram_base, (void**)&p_sh4rcb); + #endif - if (virt_ram_base==0) - return _vmem_reserve_nonvmem(); - - p_sh4rcb=(Sh4RCB*)virt_ram_base; + // Fallback to statically allocated buffers, this results in slow-ops being generated. + if (vmemstatus == MemTypeError) { + printf("Warning! nvmem is DISABLED (due to failure or not being built-in\n"); + virt_ram_base = 0; - // Map the sh4 context but protect access to Sh4RCB.fpcb[] -#if HOST_OS==OS_WINDOWS - //verify(p_sh4rcb==VirtualAlloc(p_sh4rcb,sizeof(Sh4RCB),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE)); - verify(p_sh4rcb==VirtualAlloc(p_sh4rcb,sizeof(Sh4RCB),MEM_RESERVE,PAGE_NOACCESS)); + // Allocate it all and initialize it. + p_sh4rcb = (Sh4RCB*)malloc_pages(sizeof(Sh4RCB)); + bm_vmem_pagefill((void**)p_sh4rcb->fpcb, sizeof(p_sh4rcb->fpcb)); - verify(VirtualAlloc((u8*)p_sh4rcb + sizeof(p_sh4rcb->fpcb),sizeof(Sh4RCB)-sizeof(p_sh4rcb->fpcb),MEM_COMMIT,PAGE_READWRITE)); -#else - verify(p_sh4rcb==mmap(p_sh4rcb,sizeof(Sh4RCB),PROT_NONE,MAP_PRIVATE | MAP_ANON, -1, 0)); - mprotect((u8*)p_sh4rcb + sizeof(p_sh4rcb->fpcb),sizeof(Sh4RCB)-sizeof(p_sh4rcb->fpcb),PROT_READ|PROT_WRITE); -#endif - virt_ram_base+=sizeof(Sh4RCB); + mem_b.size = RAM_SIZE; + mem_b.data = (u8*)malloc_pages(RAM_SIZE); - //Area 0 - //[0x00000000 ,0x00800000) -> unused - unused_buffer(0x00000000,0x00800000); + vram.size = VRAM_SIZE; + vram.data = (u8*)malloc_pages(VRAM_SIZE); - //I wonder, aica ram warps here ?.? - //I really should check teh docs before codin ;p - //[0x00800000,0x00A00000); - map_buffer(0x00800000,0x01000000,MAP_ARAM_START_OFFSET,ARAM_SIZE,false); - map_buffer(0x20000000,0x20000000+ARAM_SIZE,MAP_ARAM_START_OFFSET,ARAM_SIZE,true); + aica_ram.size = ARAM_SIZE; + aica_ram.data = (u8*)malloc_pages(ARAM_SIZE); + } + else { + printf("Info: nvmem is enabled, with addr space of size %s\n", vmemstatus == MemType4GB ? "4GB" : "512MB"); + // Map the different parts of the memory file into the new memory range we got. + #define MAP_RAM_START_OFFSET 0 + #define MAP_VRAM_START_OFFSET (MAP_RAM_START_OFFSET+RAM_SIZE) + #define MAP_ARAM_START_OFFSET (MAP_VRAM_START_OFFSET+VRAM_SIZE) + const vmem_mapping mem_mappings[] = { + {0x00000000, 0x00800000, 0, 0, false}, // Area 0 -> unused + {0x00800000, 0x01000000, MAP_ARAM_START_OFFSET, ARAM_SIZE, false}, // Aica, wraps too + {0x20000000, 0x20000000+ARAM_SIZE, MAP_ARAM_START_OFFSET, ARAM_SIZE, true}, + {0x01000000, 0x04000000, 0, 0, false}, // More unused + {0x04000000, 0x05000000, MAP_VRAM_START_OFFSET, VRAM_SIZE, true}, // Area 1 (vram, 16MB, wrapped on DC) + {0x05000000, 0x06000000, 0, 0, false}, // 32 bit path (unused) + {0x06000000, 0x07000000, MAP_VRAM_START_OFFSET, VRAM_SIZE, true}, // VRAM mirror + {0x07000000, 0x08000000, 0, 0, false}, // 32 bit path (unused) mirror + {0x08000000, 0x0C000000, 0, 0, false}, // Area 2 + {0x0C000000, 0x10000000, MAP_RAM_START_OFFSET, RAM_SIZE, true}, // Area 3 (main RAM + 3 mirrors) + {0x10000000, 0x20000000, 0, 0, false}, // Area 4-7 (unused) + }; + vmem_platform_create_mappings(&mem_mappings[0], sizeof(mem_mappings) / sizeof(mem_mappings[0])); - aica_ram.size=ARAM_SIZE; - aica_ram.data=(u8*)ptr; - //[0x01000000 ,0x04000000) -> unused - unused_buffer(0x01000000,0x04000000); - + // Point buffers to actual data pointers + aica_ram.size = ARAM_SIZE; + aica_ram.data = &virt_ram_base[0x20000000]; // Points to the writtable AICA addrspace - //Area 1 - //[0x04000000,0x05000000) -> vram (16mb, warped on dc) - map_buffer(0x04000000,0x05000000,MAP_VRAM_START_OFFSET,VRAM_SIZE,true); - - vram.size=VRAM_SIZE; - vram.data=(u8*)ptr; + vram.size = VRAM_SIZE; + vram.data = &virt_ram_base[0x04000000]; // Points to first vram mirror (writtable and lockable) - //[0x05000000,0x06000000) -> unused (32b path) - unused_buffer(0x05000000,0x06000000); - - //[0x06000000,0x07000000) -> vram mirror - map_buffer(0x06000000,0x07000000,MAP_VRAM_START_OFFSET,VRAM_SIZE,true); - - - //[0x07000000,0x08000000) -> unused (32b path) mirror - unused_buffer(0x07000000,0x08000000); - - //Area 2 - //[0x08000000,0x0C000000) -> unused - unused_buffer(0x08000000,0x0C000000); - - //Area 3 - //[0x0C000000,0x0D000000) -> main ram - //[0x0D000000,0x0E000000) -> main ram mirror - //[0x0E000000,0x0F000000) -> main ram mirror - //[0x0F000000,0x10000000) -> main ram mirror - map_buffer(0x0C000000,0x10000000,MAP_RAM_START_OFFSET,RAM_SIZE,true); - - mem_b.size=RAM_SIZE; - mem_b.data=(u8*)ptr; - - //Area 4 - //Area 5 - //Area 6 - //Area 7 - //all -> Unused - //[0x10000000,0x20000000) -> unused - unused_buffer(0x10000000,0x20000000); - - printf("vmem reserve: base: %08X, aram: %08x, vram: %08X, ram: %08X\n",virt_ram_base,aica_ram.data,vram.data,mem_b.data); + mem_b.size = RAM_SIZE; + mem_b.data = &virt_ram_base[0x0C000000]; // Main memory, first mirror + } + // Clear out memory aica_ram.Zero(); vram.Zero(); mem_b.Zero(); - printf("Mem alloc successful!\n"); - - return virt_ram_base!=0; + return true; } -void _vmem_release() -{ - if (!_nvmem_enabled()) - _vmem_release_nonvmem(); - else - { - 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 +#define freedefptr(x) \ + if (x) { free(x); x = NULL; } + +void _vmem_release() { + if (virt_ram_base) + vmem_platform_destroy(); + else { + freedefptr(p_sh4rcb); + freedefptr(vram.data); + freedefptr(aica_ram.data); + freedefptr(mem_b.data); } } -#else - -bool _vmem_reserve() -{ - return _vmem_reserve_nonvmem(); -} -void _vmem_release() -{ - _vmem_release_nonvmem(); -} -#endif diff --git a/core/hw/mem/_vmem.h b/core/hw/mem/_vmem.h index 8509fe3ac..f739b0454 100644 --- a/core/hw/mem/_vmem.h +++ b/core/hw/mem/_vmem.h @@ -1,6 +1,33 @@ #pragma once #include "types.h" +enum VMemType { + MemType4GB, + MemType512MB, + MemTypeError +}; + +struct vmem_mapping { + u32 start_address, end_address; + unsigned memoffset, memsize; + bool allow_writes; +}; + +// Platform specific vmemory API +// To initialize (maybe) the vmem subsystem +VMemType vmem_platform_init(void **vmem_base_addr, void **sh4rcb_addr); +// To reset the on-demand allocated pages. +void vmem_platform_reset_mem(void *ptr, unsigned size_bytes); +// To handle a fault&allocate an ondemand page. +void vmem_platform_ondemand_page(void *address, unsigned size_bytes); +// To create the mappings in the address space. +void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned nummaps); +// Just tries to wipe as much as possible in the relevant area. +void vmem_platform_destroy(); + +// Note: if you want to disable vmem magic in any given platform, implement the +// above functions as empty functions and make vmem_platform_init return MemTypeError. + //Typedef's //ReadMem typedef u8 DYNACALL _vmem_ReadMem8FP(u32 Address); @@ -70,4 +97,4 @@ static inline bool _nvmem_enabled() { return virt_ram_base != 0; } -void _vmem_bm_reset(); \ No newline at end of file +void _vmem_bm_reset(); diff --git a/core/hw/pvr/pvr_mem.h b/core/hw/pvr/pvr_mem.h index 722d37bf6..f2584937d 100644 --- a/core/hw/pvr/pvr_mem.h +++ b/core/hw/pvr/pvr_mem.h @@ -9,7 +9,7 @@ f32 vrf(u32 addr); u32 vri(u32 addr); //vram 32-64b -extern VArray2 vram; +extern VLockedMemory vram; //read u8 DYNACALL pvr_read_area1_8(u32 addr); u16 DYNACALL pvr_read_area1_16(u32 addr); @@ -36,4 +36,4 @@ extern "C" void DYNACALL TAWriteSQ(u32 address,u8* sqb); void YUV_init(); //registers -#define PVR_BASE 0x005F8000 \ No newline at end of file +#define PVR_BASE 0x005F8000 diff --git a/core/hw/sh4/sh4_mem.cpp b/core/hw/sh4/sh4_mem.cpp index b05c2c419..e3a76f08f 100644 --- a/core/hw/sh4/sh4_mem.cpp +++ b/core/hw/sh4/sh4_mem.cpp @@ -17,7 +17,7 @@ //main system mem -VArray2 mem_b; +VLockedMemory mem_b; void _vmem_init(); void _vmem_reset(); diff --git a/core/hw/sh4/sh4_mem.h b/core/hw/sh4/sh4_mem.h index e9a03af47..31982ab3f 100644 --- a/core/hw/sh4/sh4_mem.h +++ b/core/hw/sh4/sh4_mem.h @@ -2,7 +2,7 @@ #include "types.h" //main system mem -extern VArray2 mem_b; +extern VLockedMemory mem_b; #include "hw/mem/_vmem.h" #include "modules/mmu.h" diff --git a/core/linux/common.cpp b/core/linux/common.cpp index 3cbd62a68..50df5f662 100644 --- a/core/linux/common.cpp +++ b/core/linux/common.cpp @@ -34,7 +34,7 @@ #include "hw/sh4/dyna/ngen.h" -#if !defined(TARGET_NO_NVMEM) +#if !defined(TARGET_NO_EXCEPTIONS) bool ngen_Rewrite(unat& addr,unat retadr,unat acc); u32* ngen_readm_fail_v2(u32* ptr,u32* regs,u32 saddr); bool VramLockedWrite(u8* address); @@ -124,79 +124,13 @@ void install_fault_handler(void) sigaction(SIGILL, &act, &segv_oact); #endif } -#else // !defined(TARGET_NO_NVMEM) +#else // !defined(TARGET_NO_EXCEPTIONS) // No exceptions/nvmem dummy handlers. void install_fault_handler(void) {} -#endif // !defined(TARGET_NO_NVMEM) +#endif // !defined(TARGET_NO_EXCEPTIONS) #include -void VArray2::LockRegion(u32 offset,u32 size) -{ - #if !defined(TARGET_NO_NVMEM) - u32 inpage=offset & PAGE_MASK; - u32 rv=mprotect (data+offset-inpage, size+inpage, PROT_READ ); - if (rv!=0) - { - printf("mprotect(%8s,%08X,R) failed: %d | %d\n",data+offset-inpage,size+inpage,rv,errno); - die("mprotect failed ..\n"); - } - - #else - //printf("VA2: LockRegion\n"); - #endif -} - -void print_mem_addr() -{ - FILE *ifp, *ofp; - - char outputFilename[] = "/data/data/com.reicast.emulator/files/mem_alloc.txt"; - - ifp = fopen("/proc/self/maps", "r"); - - if (ifp == NULL) { - fprintf(stderr, "Can't open input file /proc/self/maps!\n"); - exit(1); - } - - ofp = fopen(outputFilename, "w"); - - if (ofp == NULL) { - fprintf(stderr, "Can't open output file %s!\n", - outputFilename); -#if HOST_OS == OS_LINUX - ofp = stderr; -#else - exit(1); -#endif - } - - char line [ 512 ]; - while (fgets(line, sizeof line, ifp) != NULL) { - fprintf(ofp, "%s", line); - } - - fclose(ifp); - if (ofp != stderr) - fclose(ofp); -} - -void VArray2::UnLockRegion(u32 offset,u32 size) -{ - #if !defined(TARGET_NO_NVMEM) - u32 inpage=offset & PAGE_MASK; - u32 rv=mprotect (data+offset-inpage, size+inpage, PROT_READ | PROT_WRITE); - if (rv!=0) - { - print_mem_addr(); - printf("mprotect(%8p,%08X,RW) failed: %d | %d\n",data+offset-inpage,size+inpage,rv,errno); - die("mprotect failed ..\n"); - } - #else - //printf("VA2: UnLockRegion\n"); - #endif -} double os_GetSeconds() { timeval a; diff --git a/core/linux/context.cpp b/core/linux/context.cpp index 9884ad426..7c317c401 100644 --- a/core/linux/context.cpp +++ b/core/linux/context.cpp @@ -8,7 +8,7 @@ #define __USE_GNU 1 #endif - #if !defined(TARGET_NO_NVMEM) + #if !defined(TARGET_NO_EXCEPTIONS) #include #endif #endif @@ -29,7 +29,7 @@ void bicopy(Ta& rei, Tb& seg, bool to_segfault) { void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_segfault) { -#if !defined(TARGET_NO_NVMEM) +#if !defined(TARGET_NO_EXCEPTIONS) #if HOST_CPU == CPU_ARM #if defined(__FreeBSD__) bicopy(reictx->pc, MCTX(.__gregs[_REG_PC]), to_segfault); diff --git a/core/linux/posix_vmem.cpp b/core/linux/posix_vmem.cpp new file mode 100644 index 000000000..8fcf57614 --- /dev/null +++ b/core/linux/posix_vmem.cpp @@ -0,0 +1,177 @@ + +// Implementation of the vmem related function for POSIX-like platforms. +// There's some minimal amount of platform specific hacks to support +// Android and OSX since they are slightly different in some areas. + +// This implements the VLockedMemory interface, as defined in _vmem.h +// The implementation allows it to be empty (that is, to not lock memory). + +#include +#include +#include +#include +#include +#include + +#include "hw/mem/_vmem.h" +#include "stdclass.h" + +#ifndef MAP_NOSYNC +#define MAP_NOSYNC 0 //missing from linux :/ -- could be the cause of android slowness ? +#endif + +#ifdef _ANDROID + #include + #ifndef ASHMEM_DEVICE + #define ASHMEM_DEVICE "/dev/ashmem" + #undef PAGE_MASK + #define PAGE_MASK (PAGE_SIZE-1) +#else + #define PAGE_SIZE 4096 + #define PAGE_MASK (PAGE_SIZE-1) +#endif + +// Android specific ashmem-device stuff for creating shared memory regions +int ashmem_create_region(const char *name, size_t size) { + int fd = open(ASHMEM_DEVICE, O_RDWR); + if (fd < 0) + return -1; + + if (ioctl(fd, ASHMEM_SET_SIZE, size) < 0) { + close(fd); + return -1; + } + + return fd; +} +#endif // #ifdef _ANDROID + +void VLockedMemory::LockRegion(unsigned offset, unsigned size_bytes) { + size_t inpage = offset & PAGE_MASK; + if (mprotect(&data[offset - inpage], size_bytes + inpage, PROT_READ)) { + die("mprotect failed ..\n"); + } +} + +void VLockedMemory::UnLockRegion(unsigned offset, unsigned size_bytes) { + size_t inpage = offset & PAGE_MASK; + if (mprotect(&data[offset - inpage], size_bytes + inpage, PROT_READ|PROT_WRITE)) { + // Add some way to see why it failed? gdb> info proc mappings + die("mprotect failed ..\n"); + } +} + +// Allocates memory via a fd on shmem/ahmem or even a file on disk +static int allocate_shared_filemem() { + int fd = -1; + #if defined(_ANDROID) + // Use Android's specific shmem stuff. + fd = ashmem_create_region(0, RAM_SIZE_MAX + VRAM_SIZE_MAX + ARAM_SIZE_MAX); + #else + #if HOST_OS != OS_DARWIN + fd = shm_open("/dcnzorz_mem", O_CREAT | O_EXCL | O_RDWR,S_IREAD | S_IWRITE); + shm_unlink("/dcnzorz_mem"); + #endif + + // if shmem does not work (or using OSX) fallback to a regular file on disk + if (fd < 0) { + string path = get_writable_data_path("/dcnzorz_mem"); + fd = open(path.c_str(), O_CREAT|O_RDWR|O_TRUNC, S_IRWXU|S_IRWXG|S_IRWXO); + unlink(path.c_str()); + } + // If we can't open the file, fallback to slow mem. + if (fd < 0) + return -1; + + // Finally make the file as big as we need! + if (ftruncate(fd, RAM_SIZE_MAX + VRAM_SIZE_MAX + ARAM_SIZE_MAX)) { + // Can't get as much memory as needed, fallback. + close(fd); + return -1; + } + #endif + + return fd; +} + +// Implement vmem initialization for RAM, ARAM, VRAM and SH4 context, fpcb etc. +// The function supports allocating 512MB or 4GB addr spaces. + +static int shmem_fd = -1; + +// vmem_base_addr points to an address space of 512MB (or 4GB) that can be used for fast memory ops. +// In negative offsets of the pointer (up to FPCB size, usually 65/129MB) the context and jump table +// can be found. If the platform init returns error, the user is responsible for initializing the +// memory using a fallback (that is, regular mallocs and falling back to slow memory JIT). +VMemType vmem_platform_init(void **vmem_base_addr, void **sh4rcb_addr) { + // Firt let's try to allocate the shm-backed memory + shmem_fd = allocate_shared_filemem(); + if (shmem_fd < 0) + return MemTypeError; + + // Now try to allocate a contiguous piece of memory. + unsigned memsize = 512*1024*1024 + sizeof(Sh4RCB) + ARAM_SIZE_MAX + 0x10000; + void *first_ptr = mmap(0, memsize, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); + if (!first_ptr) { + close(shmem_fd); + return MemTypeError; + } + + // Align pointer to 64KB too, some Linaro bug (no idea but let's just be safe I guess). + uintptr_t ptrint = (uintptr_t)first_ptr; + ptrint = (ptrint + 0x10000 - 1) & (~0xffff); + *sh4rcb_addr = (void*)ptrint; + *vmem_base_addr = (void*)(ptrint + sizeof(Sh4RCB)); + void *sh4rcb_base_ptr = (void*)(ptrint + FPCB_SIZE); + + // Now map the memory for the SH4 context, do not include FPCB on purpose (paged on demand). + mprotect(sh4rcb_base_ptr, sizeof(Sh4RCB) - FPCB_SIZE, PROT_READ | PROT_WRITE); + + return MemType512MB; +} + +// Just tries to wipe as much as possible in the relevant area. +void vmem_platform_destroy() { + munmap(virt_ram_base, 0x20000000); +} + +// Resets a chunk of memory by deleting its data and setting its protection back. +void vmem_platform_reset_mem(void *ptr, unsigned size_bytes) { + // Mark them as non accessible. + mprotect(ptr, size_bytes, PROT_NONE); + // Tell the kernel to flush'em all (FIXME: perhaps unmap+mmap 'd be better?) + madvise(ptr, size_bytes, MADV_DONTNEED); + #ifdef MADV_REMOVE + madvise(ptr, size_bytes, MADV_REMOVE); + #endif + madvise(ptr, size_bytes, MADV_FREE); +} + +// Allocates a bunch of memory (page aligned and page-sized) +void vmem_platform_ondemand_page(void *address, unsigned size_bytes) { + verify(!mprotect(address, size_bytes, PROT_READ | PROT_WRITE)); +} + +// Creates mappings to the underlying file including mirroring sections +void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned nummaps) { + for (unsigned i = 0; i < nummaps; i++) { + // Ignore unmapped stuff, it is already reserved as PROT_NONE + if (!vmem_maps[i].memsize) + continue; + + // Calculate the number of mirrors + unsigned address_range_size = vmem_maps[i].end_address - vmem_maps[i].start_address; + unsigned num_mirrors = (address_range_size) / vmem_maps[i].memsize; + int protection = vmem_maps[i].allow_writes ? (PROT_READ | PROT_WRITE) : PROT_READ; + verify((address_range_size % vmem_maps[i].memsize) == 0 && num_mirrors >= 1); + + for (unsigned j = 0; j < num_mirrors; j++) { + unsigned offset = vmem_maps[i].start_address + j * vmem_maps[i].memsize; + verify(!munmap(&virt_ram_base[offset], vmem_maps[i].memsize)); + verify(MAP_FAILED != mmap(&virt_ram_base[offset], vmem_maps[i].memsize, protection, + MAP_SHARED | MAP_NOSYNC | MAP_FIXED, shmem_fd, vmem_maps[i].memoffset)); + // ??? (mprotect(rv,size,prot)!=0) + } + } +} + diff --git a/core/rend/TexCache.cpp b/core/rend/TexCache.cpp index b0480c273..df904ed22 100644 --- a/core/rend/TexCache.cpp +++ b/core/rend/TexCache.cpp @@ -124,8 +124,7 @@ void palette_update() using namespace std; vector VramLocks[VRAM_SIZE/PAGE_SIZE]; -//vram 32-64b -VArray2 vram; +VLockedMemory vram; // vram 32-64b //List functions // @@ -207,7 +206,7 @@ vram_block* libCore_vramlock_Lock(u32 start_offset64,u32 end_offset64,void* user { vramlist_lock.Lock(); - vram.LockRegion(block->start,block->len); + vram.LockRegion(block->start, block->len); //TODO: Fix this for 32M wrap as well if (_nvmem_enabled() && VRAM_SIZE == 0x800000) { diff --git a/core/serialize.cpp b/core/serialize.cpp index 1d7fec35b..47b6eb0ca 100644 --- a/core/serialize.cpp +++ b/core/serialize.cpp @@ -101,7 +101,7 @@ extern AicaTimer timers[3]; //./core/hw/aica/aica_if.o -extern VArray2 aica_ram; +extern VLockedMemory aica_ram; extern u32 VREG;//video reg =P extern u32 ARMRST;//arm reset reg extern u32 rtc_EN; @@ -381,7 +381,7 @@ extern DECL_ALIGN(4) u32 SFaceOffsColor; //extern vector VramLocks[/*VRAM_SIZE*/(16*1024*1024)/PAGE_SIZE]; //maybe - probably not - just a locking mechanism //extern cMutex vramlist_lock; -extern VArray2 vram; +extern VLockedMemory vram; @@ -403,7 +403,7 @@ extern Array SCIF; //SCIF : 10 registers //./core/hw/sh4/sh4_mem.o -extern VArray2 mem_b; +extern VLockedMemory mem_b; //one-time init //extern _vmem_handler area1_32b; //one-time init diff --git a/core/stdclass.h b/core/stdclass.h index f5e87e6cb..04e9142db 100644 --- a/core/stdclass.h +++ b/core/stdclass.h @@ -279,29 +279,38 @@ string get_game_save_prefix(); string get_game_basename(); string get_game_dir(); -class VArray2 -{ + +// Locked memory class, used for texture invalidation purposes. +class VLockedMemory { public: - u8* data; - u32 size; - //void Init(void* data,u32 sz); - //void Term(); - void LockRegion(u32 offset,u32 size); - void UnLockRegion(u32 offset,u32 size); + unsigned size; - void Zero() - { - UnLockRegion(0,size); - memset(data,0,size); + void SetRegion(void* ptr, unsigned size) { + this->data = (u8*)ptr; + this->size = size; + } + void *getPtr() const { return data; } + unsigned getSize() const { return size; } + + #ifdef TARGET_NO_EXCEPTIONS + void LockRegion(unsigned offset, unsigned size_bytes) {} + void UnLockRegion(unsigned offset, unsigned size_bytes) {} + #else + void LockRegion(unsigned offset, unsigned size_bytes); + void UnLockRegion(unsigned offset, unsigned size_bytes); + #endif + + void Zero() { + UnLockRegion(0, size); + memset(data, 0, size); } - INLINE u8& operator [](const u32 i) - { + INLINE u8& operator [](unsigned i) { #ifdef MEM_BOUND_CHECK - if (i>=size) + if (i >= size) { - printf("Error: VArray2 , index out of range (%d>%d)\n",i,size-1); + printf("Error: VLockedMemory , index out of range (%d > %d)\n", i, size-1); MEM_DO_BREAK; } #endif @@ -309,6 +318,7 @@ public: } }; + int msgboxf(const wchar* text,unsigned int type,...); diff --git a/core/windows/win_vmem.cpp b/core/windows/win_vmem.cpp new file mode 100644 index 000000000..b1434b7e2 --- /dev/null +++ b/core/windows/win_vmem.cpp @@ -0,0 +1,96 @@ + +#define _WIN32_WINNT 0x0500 +#include +#include + +// Implementation of the vmem related function for Windows platforms. +// For now this probably does some assumptions on the CPU/platform. + +// This implements the VLockedMemory interface, as defined in _vmem.h +// The implementation allows it to be empty (that is, to not lock memory). + +void VLockedMemory::LockRegion(unsigned offset, unsigned size) { + verify(offset + size < this->size && size != 0); + DWORD old; + VirtualProtect(&data[offset], size, PAGE_READONLY, &old); +} + +void VLockedMemory::UnLockRegion(unsigned offset, unsigned size) { + verify(offset + size <= this->size && size != 0); + DWORD old; + VirtualProtect(&data[offset], size, PAGE_READWRITE, &old); +} + +static HANDLE mem_handle = INVALID_HANDLE_VALUE; +static char * base_alloc = NULL; + +// Implement vmem initialization for RAM, ARAM, VRAM and SH4 context, fpcb etc. +// The function supports allocating 512MB or 4GB addr spaces. + +// Plase read the POSIX implementation for more information. On Windows this is +// rather straightforward. +VMemType vmem_platform_init(void *vmem_base_addr, void *sh4rcb_addr) { + // Firt let's try to allocate the in-memory file + mem_handle = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, RAM_SIZE_MAX + VRAM_SIZE_MAX + ARAM_SIZE_MAX, 0); + + // Now allocate the actual address space (it will be 64KB aligned on windows). + unsigned memsize = 512*1024*1024 + sizeof(Sh4RCB) + ARAM_SIZE_MAX; + base_alloc = (char*)VirtualAlloc(0, memsize, MEM_RESERVE, PAGE_NOACCESS); + + // Calculate pointers now + sh4rcb_addr = &base_alloc[0]; + vmem_base_addr = &base_alloc[sizeof(Sh4RCB)]; + + return MemType512MB; +} + +// Just tries to wipe as much as possible in the relevant area. +void vmem_platform_destroy() { + VirtualFree(base_alloc, 0, MEM_RELEASE); + CloseHandle(mem_handle); +} + +// Resets a chunk of memory by deleting its data and setting its protection back. +void vmem_platform_reset_mem(void *ptr, unsigned size_bytes) { + VirtualFree(ptr, size_bytes, MEM_DECOMMIT); +} + +// Allocates a bunch of memory (page aligned and page-sized) +void vmem_platform_ondemand_page(void *address, unsigned size_bytes) { + verify(VirtualAlloc(address, size_bytes, MEM_COMMIT, PAGE_READWRITE)); +} + +/// Creates mappings to the underlying file including mirroring sections +void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned nummaps) { + // Since this is tricky to get right in Windows (in posix one can just unmap sections and remap later) + // we unmap the whole thing only to remap it later. + + // Unmap the whole section + VirtualFree(base_alloc, 0, MEM_RELEASE); + + for (unsigned i = 0; i < nummaps; i++) { + unsigned address_range_size = vmem_maps[i].end_address - vmem_maps[i].start_address; + DWORD protection = vmem_maps[i].allow_writes ? (FILE_MAP_READ | FILE_MAP_WRITE) : FILE_MAP_READ; + + if (!vmem_maps[i].memsize) { + // Unmapped stuff goes with a protected area or memory. Prevent anything from allocating here + void *ptr = VirtualAlloc(&virt_ram_base[vmem_maps[i].start_address], address_range_size, MEM_RESERVE, PAGE_NOACCESS); + verify(ptr == &virt_ram_base[vmem_maps[i].start_address]); + } + else { + // Calculate the number of mirrors + unsigned num_mirrors = (address_range_size) / vmem_maps[i].memsize; + verify((address_range_size % vmem_maps[i].memsize) == 0 && num_mirrors >= 1); + + // Remap the views one by one + for (unsigned j = 0; j < num_mirrors; j++) { + unsigned offset = vmem_maps[i].start_address + j * vmem_maps[i].memsize; + + void *ptr = MapViewOfFileEx(mem_handle, protection, 0, vmem_maps[i].memoffset, + vmem_maps[i].memsize, &virt_ram_base[vmem_maps[i].start_address]); + verify(ptr == &virt_ram_base[vmem_maps[i].start_address]); + } + } + } +} + diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 029ba1246..44633ab0d 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -148,12 +148,10 @@ LONG ExeptionHandler(EXCEPTION_POINTERS *ExceptionInfo) { return EXCEPTION_CONTINUE_EXECUTION; } -#ifndef TARGET_NO_NVMEM else if (BM_LockedWrite(address)) { return EXCEPTION_CONTINUE_EXECUTION; } -#endif #if FEAT_SHREC == DYNAREC_JIT && HOST_CPU == CPU_X86 else if ( ngen_Rewrite((unat&)ep->ContextRecord->Eip,*(unat*)ep->ContextRecord->Esp,ep->ContextRecord->Eax) ) { @@ -800,21 +798,5 @@ void os_DoEvents() } } - -void VArray2::LockRegion(u32 offset,u32 size) -{ - //verify(offset+sizesize); - verify(size!=0); - DWORD old; - VirtualProtect(((u8*)data)+offset , size, PAGE_READONLY,&old); -} -void VArray2::UnLockRegion(u32 offset,u32 size) -{ - //verify(offset+size<=this->size); - verify(size!=0); - DWORD old; - VirtualProtect(((u8*)data)+offset , size, PAGE_READWRITE,&old); -} - int get_mic_data(u8* buffer) { return 0; } int push_vmu_screen(u8* buffer) { return 0; } diff --git a/shell/cmake/config.cmake b/shell/cmake/config.cmake index 056b7e74a..d1dfd59e4 100644 --- a/shell/cmake/config.cmake +++ b/shell/cmake/config.cmake @@ -343,7 +343,7 @@ if (TARGET_NSW) # -DCMAKE_TOOLCHAIN_FILE=./cmake/devkitA64.cmake -DTARGET_NSW=ON message("HOST_OS ${HOST_OS}") add_definitions(-D__SWITCH__ -DGLES -DMESA_EGL_NO_X11_HEADERS) - add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_NVMEM -DTARGET_NO_NIXPROF) + add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_EXCEPTIONS -DTARGET_NO_NIXPROF) add_definitions(-DTARGET_NO_COREIO_HTTP -DTARGET_NO_WEBUI -UTARGET_SOFTREND) add_definitions(-D_GLIBCXX_USE_C99_MATH_TR1 -D_LDBL_EQ_DBL) @@ -355,7 +355,7 @@ if (TARGET_PS4) # -DCMAKE_TOOLCHAIN_FILE=./cmake/{ps4sdk,clang_scei}.cmake -DTAR add_definitions(-DPS4 -DTARGET_PS4 -DTARGET_BSD -D__ORBIS__ -DGLES -DMESA_EGL_NO_X11_HEADERS) ## last needed for __unix__ on eglplatform.h - add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_NVMEM -DTARGET_NO_NIXPROF) + add_definitions(-DTARGET_NO_THREADS -DTARGET_NO_EXCEPTIONS -DTARGET_NO_NIXPROF) add_definitions(-DTARGET_NO_COREIO_HTTP -DTARGET_NO_WEBUI -UTARGET_SOFTREND) diff --git a/shell/emscripten/Makefile b/shell/emscripten/Makefile index 1c74e19b6..1b8ef4c22 100644 --- a/shell/emscripten/Makefile +++ b/shell/emscripten/Makefile @@ -26,7 +26,7 @@ LDFLAGS := -Wl,-Map,$(notdir $@).map,--gc-sections -Wl,-O3 -Wl,--sort-common CXXONLYFLAGS := -std=c++11 -CXXFLAGS := -O3 -D GLES -D RELEASE -c -D TARGET_EMSCRIPTEN -D TARGET_NO_REC -D TARGET_NO_NVMEM -D TARGET_NO_WEBUI -D TARGET_NO_THREADS -D TARGET_BOUNDED_EXECUTION -D TARGET_NO_COREIO_HTTP +CXXFLAGS := -O3 -D GLES -D RELEASE -c -D TARGET_EMSCRIPTEN -D TARGET_NO_REC -D TARGET_NO_EXCEPTIONS -D TARGET_NO_WEBUI -D TARGET_NO_THREADS -D TARGET_BOUNDED_EXECUTION -D TARGET_NO_COREIO_HTTP CXXFLAGS += -fno-strict-aliasing CXXFLAGS += -ffast-math diff --git a/shell/nacl/Makefile b/shell/nacl/Makefile index e0d03834e..fec9cf250 100644 --- a/shell/nacl/Makefile +++ b/shell/nacl/Makefile @@ -23,7 +23,7 @@ CFLAGS = -Wno-error -Wno-ignored-attributes CFLAGS += -O3 -fno-strict-aliasing -ffast-math CFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps CFLAGS += -D RELEASE -D TARGET_NO_JIT -D TARGET_NACL32 -DGLES -CFLAGS += -D TARGET_NO_NVMEM -D TARGET_NO_WEBUI -D TARGET_NO_COREIO_HTTP +CFLAGS += -D TARGET_NO_EXCEPTIONS -D TARGET_NO_WEBUI -D TARGET_NO_COREIO_HTTP SOURCES = $(RZDCY_FILES) ../../core/nacl/nacl.cpp From 4458dac49ab4a27637f253aa3b8bfee4d301a07c Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 11 May 2019 22:35:17 +0200 Subject: [PATCH 67/73] Fixing some missing imports and a bug in pointer tracking. --- core/windows/win_vmem.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/windows/win_vmem.cpp b/core/windows/win_vmem.cpp index b1434b7e2..44d3deabc 100644 --- a/core/windows/win_vmem.cpp +++ b/core/windows/win_vmem.cpp @@ -3,6 +3,8 @@ #include #include +#include "hw/mem/_vmem.h" + // Implementation of the vmem related function for Windows platforms. // For now this probably does some assumptions on the CPU/platform. @@ -29,7 +31,7 @@ static char * base_alloc = NULL; // Plase read the POSIX implementation for more information. On Windows this is // rather straightforward. -VMemType vmem_platform_init(void *vmem_base_addr, void *sh4rcb_addr) { +VMemType vmem_platform_init(void **vmem_base_addr, void **sh4rcb_addr) { // Firt let's try to allocate the in-memory file mem_handle = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, RAM_SIZE_MAX + VRAM_SIZE_MAX + ARAM_SIZE_MAX, 0); @@ -38,8 +40,8 @@ VMemType vmem_platform_init(void *vmem_base_addr, void *sh4rcb_addr) { base_alloc = (char*)VirtualAlloc(0, memsize, MEM_RESERVE, PAGE_NOACCESS); // Calculate pointers now - sh4rcb_addr = &base_alloc[0]; - vmem_base_addr = &base_alloc[sizeof(Sh4RCB)]; + *sh4rcb_addr = &base_alloc[0]; + *vmem_base_addr = &base_alloc[sizeof(Sh4RCB)]; return MemType512MB; } From 4e5053be20c765286837dff99ee1e411314bfde1 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 11 May 2019 22:38:57 +0200 Subject: [PATCH 68/73] Adding win_vmem.cpp to VC project files. --- shell/reicast.vcxproj | 3 ++- shell/reicast.vcxproj.filters | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/shell/reicast.vcxproj b/shell/reicast.vcxproj index 3d10f789a..93904ce9a 100644 --- a/shell/reicast.vcxproj +++ b/shell/reicast.vcxproj @@ -322,6 +322,7 @@ + @@ -998,4 +999,4 @@ for /f "delims=" %%i in ('date /T') do echo #define BUILD_DATE "%%i" >>$(P - \ No newline at end of file + diff --git a/shell/reicast.vcxproj.filters b/shell/reicast.vcxproj.filters index 1f347b584..59289b0b3 100644 --- a/shell/reicast.vcxproj.filters +++ b/shell/reicast.vcxproj.filters @@ -129,6 +129,9 @@ windows + + windows + profiler @@ -1397,4 +1400,4 @@ - \ No newline at end of file + From 1a4323c1ce3579e797ef00a2dd2a3454f0da6597 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sat, 11 May 2019 23:04:22 +0200 Subject: [PATCH 69/73] Fix runtime issue in Windows target, was not mapping pages correctly. --- core/windows/win_vmem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/windows/win_vmem.cpp b/core/windows/win_vmem.cpp index 44d3deabc..32e250a50 100644 --- a/core/windows/win_vmem.cpp +++ b/core/windows/win_vmem.cpp @@ -89,8 +89,8 @@ void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned numma unsigned offset = vmem_maps[i].start_address + j * vmem_maps[i].memsize; void *ptr = MapViewOfFileEx(mem_handle, protection, 0, vmem_maps[i].memoffset, - vmem_maps[i].memsize, &virt_ram_base[vmem_maps[i].start_address]); - verify(ptr == &virt_ram_base[vmem_maps[i].start_address]); + vmem_maps[i].memsize, &virt_ram_base[offset]); + verify(ptr == &virt_ram_base[offset]); } } } From 6cba98b70ae490621f65a73860226a869de3f842 Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sun, 12 May 2019 00:02:24 +0200 Subject: [PATCH 70/73] Allocate missing SH4CB and make lock more forgiving. --- core/windows/win_vmem.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/windows/win_vmem.cpp b/core/windows/win_vmem.cpp index 32e250a50..2e456198c 100644 --- a/core/windows/win_vmem.cpp +++ b/core/windows/win_vmem.cpp @@ -12,13 +12,13 @@ // The implementation allows it to be empty (that is, to not lock memory). void VLockedMemory::LockRegion(unsigned offset, unsigned size) { - verify(offset + size < this->size && size != 0); + //verify(offset + size < this->size && size != 0); DWORD old; VirtualProtect(&data[offset], size, PAGE_READONLY, &old); } void VLockedMemory::UnLockRegion(unsigned offset, unsigned size) { - verify(offset + size <= this->size && size != 0); + //verify(offset + size <= this->size && size != 0); DWORD old; VirtualProtect(&data[offset], size, PAGE_READWRITE, &old); } @@ -70,6 +70,12 @@ void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned numma // Unmap the whole section VirtualFree(base_alloc, 0, MEM_RELEASE); + // Map the SH4CB block too + void *base_ptr = VirtualAlloc(base_alloc, sizeof(Sh4RCB), MEM_RESERVE, PAGE_NOACCESS); + verify(base_ptr == base_alloc); + void *cntx_ptr = VirtualAlloc((u8*)p_sh4rcb + sizeof(p_sh4rcb->fpcb), sizeof(Sh4RCB) - sizeof(p_sh4rcb->fpcb), MEM_COMMIT, PAGE_READWRITE); + verify(cntx_ptr == (u8*)p_sh4rcb + sizeof(p_sh4rcb->fpcb)); + for (unsigned i = 0; i < nummaps; i++) { unsigned address_range_size = vmem_maps[i].end_address - vmem_maps[i].start_address; DWORD protection = vmem_maps[i].allow_writes ? (FILE_MAP_READ | FILE_MAP_WRITE) : FILE_MAP_READ; From 55e7c170302d3a0f6d98673ce787e4d7b999b3cd Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sun, 12 May 2019 13:40:18 +0200 Subject: [PATCH 71/73] Fix minor build issue with madvise flags. --- core/hw/mem/_vmem.cpp | 2 +- core/linux/posix_vmem.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/hw/mem/_vmem.cpp b/core/hw/mem/_vmem.cpp index 9a297330c..3fbfdf6b5 100644 --- a/core/hw/mem/_vmem.cpp +++ b/core/hw/mem/_vmem.cpp @@ -478,7 +478,7 @@ bool _vmem_reserve() { {0x00800000, 0x01000000, MAP_ARAM_START_OFFSET, ARAM_SIZE, false}, // Aica, wraps too {0x20000000, 0x20000000+ARAM_SIZE, MAP_ARAM_START_OFFSET, ARAM_SIZE, true}, {0x01000000, 0x04000000, 0, 0, false}, // More unused - {0x04000000, 0x05000000, MAP_VRAM_START_OFFSET, VRAM_SIZE, true}, // Area 1 (vram, 16MB, wrapped on DC) + {0x04000000, 0x05000000, MAP_VRAM_START_OFFSET, VRAM_SIZE, true}, // Area 1 (vram, 16MB, wrapped on DC as 2x8MB) {0x05000000, 0x06000000, 0, 0, false}, // 32 bit path (unused) {0x06000000, 0x07000000, MAP_VRAM_START_OFFSET, VRAM_SIZE, true}, // VRAM mirror {0x07000000, 0x08000000, 0, 0, false}, // 32 bit path (unused) mirror diff --git a/core/linux/posix_vmem.cpp b/core/linux/posix_vmem.cpp index 8fcf57614..3601eef1b 100644 --- a/core/linux/posix_vmem.cpp +++ b/core/linux/posix_vmem.cpp @@ -141,10 +141,11 @@ void vmem_platform_reset_mem(void *ptr, unsigned size_bytes) { mprotect(ptr, size_bytes, PROT_NONE); // Tell the kernel to flush'em all (FIXME: perhaps unmap+mmap 'd be better?) madvise(ptr, size_bytes, MADV_DONTNEED); - #ifdef MADV_REMOVE + #if defined(MADV_REMOVE) madvise(ptr, size_bytes, MADV_REMOVE); - #endif - madvise(ptr, size_bytes, MADV_FREE); + #elif defined(MADV_FREE) + madvise(ptr, size_bytes, MADV_FREE); + #endif } // Allocates a bunch of memory (page aligned and page-sized) From 15ce3ab5fae15c61edfb93094bc8572dc80d28ab Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sun, 12 May 2019 16:53:30 +0200 Subject: [PATCH 72/73] OSX build fixes --- core/linux/common.cpp | 4 ---- core/oslib/audiobackend_coreaudio.cpp | 2 +- core/stdclass.cpp | 4 ++++ .../apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/linux/common.cpp b/core/linux/common.cpp index 50df5f662..ce9194436 100644 --- a/core/linux/common.cpp +++ b/core/linux/common.cpp @@ -23,10 +23,6 @@ #include #include #endif -#if HOST_OS == OS_DARWIN -#include -#include -#endif #include #include "hw/sh4/dyna/blockmanager.h" diff --git a/core/oslib/audiobackend_coreaudio.cpp b/core/oslib/audiobackend_coreaudio.cpp index 8e0e9b344..4f7cb44a8 100644 --- a/core/oslib/audiobackend_coreaudio.cpp +++ b/core/oslib/audiobackend_coreaudio.cpp @@ -28,7 +28,7 @@ static u8 samples_temp[BUFSIZE]; static std::atomic samples_wptr; static std::atomic samples_rptr; -static cResetEvent bufferEmpty(false, true); +static cResetEvent bufferEmpty; static OSStatus coreaudio_callback(void* ctx, AudioUnitRenderActionFlags* flags, const AudioTimeStamp* ts, UInt32 bus, UInt32 frames, AudioBufferList* abl) diff --git a/core/stdclass.cpp b/core/stdclass.cpp index 05cc49013..76921d170 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -5,6 +5,10 @@ #include "types.h" #include "cfg/cfg.h" #include "stdclass.h" +#if HOST_OS == OS_DARWIN +#include +#include +#endif #if COMPILER_VC_OR_CLANG_WIN32 diff --git a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj index cff1dafd5..835041b08 100644 --- a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj +++ b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj @@ -266,6 +266,7 @@ AEE6278E2224762000EC7E89 /* imgui_impl_opengl3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEE6278B2224762000EC7E89 /* imgui_impl_opengl3.cpp */; }; AEE6279422247C0A00EC7E89 /* gui_util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEE6279222247C0A00EC7E89 /* gui_util.cpp */; }; AEE6279622247C2B00EC7E89 /* keyboard_device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEE6279522247C2B00EC7E89 /* keyboard_device.cpp */; }; + AEF2564822886A2E00348550 /* posix_vmem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEF2564722886A2E00348550 /* posix_vmem.cpp */; }; AEFF7ECC214AEC810068CE11 /* modem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEFF7EC7214AEC800068CE11 /* modem.cpp */; }; AEFF7F4D214D9D590068CE11 /* pico_arp.c in Sources */ = {isa = PBXBuildFile; fileRef = AEFF7EFA214D9D590068CE11 /* pico_arp.c */; }; AEFF7F4E214D9D590068CE11 /* pico_dev_ppp.c in Sources */ = {isa = PBXBuildFile; fileRef = AEFF7EFE214D9D590068CE11 /* pico_dev_ppp.c */; }; @@ -803,6 +804,7 @@ AEE6279222247C0A00EC7E89 /* gui_util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gui_util.cpp; sourceTree = ""; }; AEE6279322247C0A00EC7E89 /* gui_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gui_util.h; sourceTree = ""; }; AEE6279522247C2B00EC7E89 /* keyboard_device.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = keyboard_device.cpp; sourceTree = ""; }; + AEF2564722886A2E00348550 /* posix_vmem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = posix_vmem.cpp; sourceTree = ""; }; AEFF7EC7214AEC800068CE11 /* modem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = modem.cpp; sourceTree = ""; }; AEFF7EC8214AEC800068CE11 /* modem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = modem.h; sourceTree = ""; }; AEFF7EC9214AEC800068CE11 /* modem_regs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = modem_regs.h; sourceTree = ""; }; @@ -1556,6 +1558,7 @@ 84B7BE661B72720100F9733F /* context.cpp */, 84B7BE671B72720100F9733F /* context.h */, 84B7BE681B72720100F9733F /* nixprof */, + AEF2564722886A2E00348550 /* posix_vmem.cpp */, 84B7BE6A1B72720100F9733F /* typedefs.h */, ); name = linux; @@ -2310,6 +2313,7 @@ 84B7BF131B72720200F9733F /* zip_unchange_all.c in Sources */, 84B7BF541B72720200F9733F /* sh4_interrupts.cpp in Sources */, AE2A2D7F21D6851E004B308D /* 7zFile.c in Sources */, + AEF2564822886A2E00348550 /* posix_vmem.cpp in Sources */, 84B7BF6B1B72720200F9733F /* audiostream.cpp in Sources */, 84B7BEFB1B72720200F9733F /* zip_get_file_comment.c in Sources */, 84B7BF301B72720200F9733F /* holly_intc.cpp in Sources */, From cbc2af29ad306975be77c9227e9c6e3380ce1a6c Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Sun, 12 May 2019 17:41:42 +0200 Subject: [PATCH 73/73] Fix small issues for mingw builds on Linux Doenst like the paths, big surprise. I tipically build it like: make platform=win32 CXX=x86_64-w64-mingw32-g++ \ WINDRES=x86_64-w64-mingw32-windres \ CC=x86_64-w64-mingw32-gcc --- core/imgread/ioctl.cpp | 4 ++-- core/rend/d3d11/d3d11.cpp | 6 +++--- core/rend/gles/gles.cpp | 2 +- core/stdclass.h | 2 +- core/windows/winmain.cpp | 10 +++++----- core/windows/xinput_gamepad.h | 2 +- shell/linux/Makefile | 3 ++- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/core/imgread/ioctl.cpp b/core/imgread/ioctl.cpp index 4486dc99a..9dfd66b43 100644 --- a/core/imgread/ioctl.cpp +++ b/core/imgread/ioctl.cpp @@ -4,7 +4,7 @@ #include "common.h" #include -#include +#include #include #include "SCSIDEFS.H" @@ -388,4 +388,4 @@ Disc* ioctl_parse(const wchar* file) } } -#endif \ No newline at end of file +#endif diff --git a/core/rend/d3d11/d3d11.cpp b/core/rend/d3d11/d3d11.cpp index bf059af21..974ac94e8 100644 --- a/core/rend/d3d11/d3d11.cpp +++ b/core/rend/d3d11/d3d11.cpp @@ -1,6 +1,6 @@ #include -#include "hw\pvr\Renderer_if.h" -#include "oslib\oslib.h" +#include "hw/pvr/Renderer_if.h" +#include "oslib/oslib.h" #pragma comment(lib,"d3d11.lib") @@ -102,4 +102,4 @@ struct d3d11 : Renderer Renderer* rend_D3D11() { return new d3d11(); -} \ No newline at end of file +} diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index 9e7c812a2..ea67babf0 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -783,7 +783,7 @@ GLuint fogTextureId; return rv; } - #include + #include void gl_swap() { wglSwapLayerBuffers(ourWindowHandleToDeviceContext,WGL_SWAP_MAIN_PLANE); diff --git a/core/stdclass.h b/core/stdclass.h index 04e9142db..e7f8d2685 100644 --- a/core/stdclass.h +++ b/core/stdclass.h @@ -7,7 +7,7 @@ #if HOST_OS!=OS_WINDOWS #include #else -#include +#include #endif diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 44633ab0d..adec1ffa9 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -1,6 +1,6 @@ -#include "oslib\oslib.h" -#include "oslib\audiostream.h" -#include "imgread\common.h" +#include "oslib/oslib.h" +#include "oslib/audiostream.h" +#include "imgread/common.h" #include "stdclass.h" #include "cfg/cfg.h" #include "xinput_gamepad.h" @@ -10,8 +10,8 @@ #include #include -#include -#include "hw\maple\maple_cfg.h" +#include +#include "hw/maple/maple_cfg.h" #pragma comment(lib, "XInput9_1_0.lib") PCHAR* diff --git a/core/windows/xinput_gamepad.h b/core/windows/xinput_gamepad.h index 336df20e4..beb311413 100644 --- a/core/windows/xinput_gamepad.h +++ b/core/windows/xinput_gamepad.h @@ -1,4 +1,4 @@ -#include +#include #include "input/gamepad_device.h" #include "rend/gui.h" diff --git a/shell/linux/Makefile b/shell/linux/Makefile index f48d5eb08..c3a32668a 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -18,6 +18,7 @@ CC=${CC_PREFIX}gcc AS=${CC_PREFIX}as STRIP=${CC_PREFIX}strip LD=${CC} +WINDRES=${CC_PREFIX}windres CHD5_LZMA := 1 CHD5_FLAC := 1 @@ -432,7 +433,7 @@ OBJECTS:=$(patsubst $(RZDCY_SRC_DIR)/%,$(BUILDDIR)/%,$(OBJECTS)) ifdef FOR_WINDOWS OBJECTS+=$(BUILDDIR)/reicastres.build_obj $(BUILDDIR)/reicastres.build_obj: $(LOCAL_PATH)/../windows/reicast.rc $(LOCAL_PATH)/../windows/reicast.ico $(RZDCY_SRC_DIR)/version.h - windres $< $@ + $(WINDRES) $< $@ endif DEPDIR := .dep-$(BUILDDIR)