diff --git a/RA_Integration b/RA_Integration index 8baa8494..b101ed7a 160000 --- a/RA_Integration +++ b/RA_Integration @@ -1 +1 @@ -Subproject commit 8baa8494f81c59cb9af15bd8be104fd03ff9ade0 +Subproject commit b101ed7a05f3710c9937897b6cadacae6bb745bf diff --git a/RAppleWin/source/Applewin.cpp b/RAppleWin/source/Applewin.cpp index 2f7cc7d5..614ce4e5 100644 --- a/RAppleWin/source/Applewin.cpp +++ b/RAppleWin/source/Applewin.cpp @@ -1766,9 +1766,11 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) bSetFullScreen = g_bRestartFullScreen; g_bRestartFullScreen = false; } - #if USE_RETROACHIEVEMENTS - RA_Shutdown(); + else + { + RA_Shutdown(); + } #endif MB_Reset(); diff --git a/RAppleWin/source/Frame.cpp b/RAppleWin/source/Frame.cpp index ee7cfb1c..15674923 100644 --- a/RAppleWin/source/Frame.cpp +++ b/RAppleWin/source/Frame.cpp @@ -172,7 +172,7 @@ static FULLSCREEN_SCALE_TYPE g_win_fullscreen_scale = 1; static int g_win_fullscreen_offsetx = 0; static int g_win_fullscreen_offsety = 0; -static bool g_bFrameActive = false; +bool g_bFrameActive = false; // __ Prototypes __________________________________________________________________________________ void DrawCrosshairs (int x, int y); diff --git a/RAppleWin/source/Frame.h b/RAppleWin/source/Frame.h index d3a156d6..0aa84a10 100644 --- a/RAppleWin/source/Frame.h +++ b/RAppleWin/source/Frame.h @@ -9,6 +9,7 @@ extern int g_nViewportCY; extern BOOL g_bConfirmReboot; // saved PageConfig REGSAVE extern BOOL g_bMultiMon; + extern bool g_bFrameActive; // Emulator diff --git a/RAppleWin/source/RetroAchievements.cpp b/RAppleWin/source/RetroAchievements.cpp index 3f4ff069..5e8a7bf6 100644 --- a/RAppleWin/source/RetroAchievements.cpp +++ b/RAppleWin/source/RetroAchievements.cpp @@ -1,5 +1,6 @@ #if USE_RETROACHIEVEMENTS +#include #include #include "RetroAchievements.h" @@ -48,23 +49,27 @@ void free_file_info(FileInfo *file) unsigned char MainRAMReader(size_t nOffs) { - return *MemGetMainPtr(nOffs); + assert(nOffs <= 0xFFFF); + return *MemGetMainPtr((WORD)nOffs); } void MainRAMWriter(size_t nOffs, unsigned char nVal) { - *MemGetMainPtr(nOffs) = nVal; + assert(nOffs <= 0xFFFF); + *MemGetMainPtr((WORD)nOffs) = nVal; } #if RA_ENABLE_AUXRAM unsigned char AuxRAMReader(size_t nOffs) { - return *MemGetAuxPtr(nOffs); + assert(nOffs <= 0xFFFF); + return *MemGetAuxPtr((WORD)nOffs); } void AuxRAMWriter(size_t nOffs, unsigned char nVal) { - *MemGetAuxPtr(nOffs) = nVal; + assert(nOffs <= 0xFFFF); + *MemGetAuxPtr((WORD)nOffs) = nVal; } #endif @@ -161,9 +166,17 @@ void RA_InitShared() void RA_InitSystem() { - RA_Init(g_hFrameWindow, RA_AppleWin, RAPPLEWIN_VERSION); - RA_InitShared(); - RA_AttemptLogin(true); + if (is_initialized) + { + RA_UpdateHWnd(g_hFrameWindow); + } + else + { + RA_Init(g_hFrameWindow, RA_AppleWin, RAPPLEWIN_VERSION); + RA_InitShared(); + RA_AttemptLogin(true); + is_initialized = true; + } confirmed_quitting = false; } @@ -217,6 +230,9 @@ int RA_PrepareLoadNewRom(const char *file_name, FileType file_type) loading_file.data_len = file_size; BYTE * const file_data = (BYTE *)malloc(file_size * sizeof(BYTE)); + if (!file_data) + return FALSE; + loading_file.data = file_data; fseek(f, 0, SEEK_SET); fread(file_data, sizeof(BYTE), file_size, f); @@ -392,14 +408,18 @@ void RA_RenderOverlayFrame(HDC hdc) int width = GetFrameBufferBorderlessWidth(), height = GetFrameBufferBorderlessHeight(); RECT window_size = { 0, 0, width, height }; - ControllerInput input; - input.m_bConfirmPressed = GetKeyState(VK_RETURN) & WM_KEYDOWN; - input.m_bCancelPressed = GetKeyState(VK_BACK) & WM_KEYDOWN; - input.m_bQuitPressed = GetKeyState(VK_ESCAPE) & WM_KEYDOWN; - input.m_bLeftPressed = GetKeyState(VK_LEFT) & WM_KEYDOWN; - input.m_bRightPressed = GetKeyState(VK_RIGHT) & WM_KEYDOWN; - input.m_bUpPressed = GetKeyState(VK_UP) & WM_KEYDOWN; - input.m_bDownPressed = GetKeyState(VK_DOWN) & WM_KEYDOWN; + ControllerInput input = {}; + + if (g_bFrameActive) // Do not process input while out of focus + { + input.m_bConfirmPressed = GetKeyState(VK_RETURN) & WM_KEYDOWN; + input.m_bCancelPressed = GetKeyState(VK_BACK) & WM_KEYDOWN; + input.m_bQuitPressed = GetKeyState(VK_ESCAPE) & WM_KEYDOWN; + input.m_bLeftPressed = GetKeyState(VK_LEFT) & WM_KEYDOWN; + input.m_bRightPressed = GetKeyState(VK_RIGHT) & WM_KEYDOWN; + input.m_bUpPressed = GetKeyState(VK_UP) & WM_KEYDOWN; + input.m_bDownPressed = GetKeyState(VK_DOWN) & WM_KEYDOWN; + } RA_UpdateRenderOverlay(hdc, &input, delta_time, &window_size, IsFullScreen(), g_nAppMode == MODE_PAUSED);