From add7ec7b98ce99df40197dd1b127b1d55733d3e4 Mon Sep 17 00:00:00 2001 From: luigiblood Date: Mon, 30 May 2016 01:09:52 +0200 Subject: [PATCH] [64DD] Make sure new disk is loaded into memory before swap Fixes hang during swap while recording with OBS Studio --- Source/Project64-core/N64System/Mips/Disk.cpp | 4 ++-- Source/Project64-core/N64System/N64DiskClass.cpp | 5 ++++- Source/Project64-core/N64System/N64DiskClass.h | 2 +- Source/Project64/UserInterface/MainMenuClass.cpp | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/Disk.cpp b/Source/Project64-core/N64System/Mips/Disk.cpp index 064e708d1..77191ec43 100644 --- a/Source/Project64-core/N64System/Mips/Disk.cpp +++ b/Source/Project64-core/N64System/Mips/Disk.cpp @@ -166,10 +166,10 @@ void DiskGapSectorCheck() } } - if (!(g_Reg->ASIC_STATUS & DD_STATUS_DISK_PRES) && g_Disk != NULL) + if (!(g_Reg->ASIC_STATUS & DD_STATUS_DISK_PRES) && g_Disk != NULL && g_Settings->LoadBool(GameRunning_LoadingInProgress) == false) { dd_swapdelay++; - if (dd_swapdelay >= 40) + if (dd_swapdelay >= 50) { g_Reg->ASIC_STATUS |= (DD_STATUS_DISK_PRES | DD_STATUS_DISK_CHNG); dd_swapdelay = 0; diff --git a/Source/Project64-core/N64System/N64DiskClass.cpp b/Source/Project64-core/N64System/N64DiskClass.cpp index 9b95c4353..4eb7d3c94 100644 --- a/Source/Project64-core/N64System/N64DiskClass.cpp +++ b/Source/Project64-core/N64System/N64DiskClass.cpp @@ -36,6 +36,8 @@ bool CN64Disk::LoadDiskImage(const char * FileLoc) stdstr ShadowFile = FileLoc; ShadowFile[ShadowFile.length() - 1] = 'r'; + g_Settings->SaveBool(GameRunning_LoadingInProgress, true); + WriteTrace(TraceN64System, TraceDebug, "Attempt to load shadow file."); if (!AllocateAndLoadDiskImage(ShadowFile.c_str())) { @@ -104,9 +106,10 @@ bool CN64Disk::SaveDiskImage() return true; } -void CN64Disk::SwapDiskImage() +void CN64Disk::SwapDiskImage(const char * FileLoc) { g_Reg->ASIC_STATUS &= ~DD_STATUS_DISK_PRES; + LoadDiskImage(FileLoc); } bool CN64Disk::IsValidDiskImage(uint8_t Test[4]) diff --git a/Source/Project64-core/N64System/N64DiskClass.h b/Source/Project64-core/N64System/N64DiskClass.h index ff8a2305e..594db44db 100644 --- a/Source/Project64-core/N64System/N64DiskClass.h +++ b/Source/Project64-core/N64System/N64DiskClass.h @@ -19,7 +19,7 @@ public: bool LoadDiskImage(const char * FileLoc); bool SaveDiskImage(); - void SwapDiskImage(); + void SwapDiskImage(const char * FileLoc); static bool IsValidDiskImage(uint8_t Test[4]); uint8_t * GetDiskAddress() { return m_DiskImage; } uint8_t * GetDiskAddressBuffer() { return m_DiskImage + m_DiskBufAddress; } diff --git a/Source/Project64/UserInterface/MainMenuClass.cpp b/Source/Project64/UserInterface/MainMenuClass.cpp index 9f75710c4..b936f83b0 100644 --- a/Source/Project64/UserInterface/MainMenuClass.cpp +++ b/Source/Project64/UserInterface/MainMenuClass.cpp @@ -252,8 +252,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI if (GetOpenFileName(&openfilename)) { g_Disk->SaveDiskImage(); - g_Disk->SwapDiskImage(); - g_Disk->LoadDiskImage(FileName); + g_Disk->SwapDiskImage(FileName); } break; case ID_SYSTEM_SAVE: