Skip to content

Commit 211e37a

Browse files
authored
Merge pull request #2496 from RadWolfie/fix-chihiro-again
Fix Chihiro console type again
2 parents cf9a2b2 + 58905c4 commit 211e37a

3 files changed

Lines changed: 8 additions & 32 deletions

File tree

projects/cxbxr-emu/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
4848

4949
# Use inline XXHash version
5050
XXH_INLINE_ALL
51-
52-
# Enable Chihiro work
53-
CHIHIRO_WORK
5451
)
5552
add_compile_options(
5653
/EHs

src/core/kernel/init/CxbxKrnl.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
#include "EmuShared.h"
4444
#include "core\hle\D3D8\Direct3D9\Direct3D9.h" // For CxbxInitWindow, EmuD3DInit
4545
#include "core\hle\DSOUND\DirectSound\DirectSound.hpp" // For CxbxInitAudio
46-
#ifdef CHIHIRO_WORK
4746
#include "core\hle\JVS\JVS.h" // For JVS_Init
48-
#endif
4947
#include "core\hle\Intercept.hpp"
5048
#include "core\kernel\memory-manager\VMManager.h"
5149
#include "CxbxDebugger.h"
@@ -589,9 +587,11 @@ static bool CxbxrKrnlXbeSystemSelector(int BootFlags,
589587
// Clear emulation system from reserved systems so all unneeded memory ranges can be freed.
590588
reserved_systems &= ~emulate_system;
591589

592-
#ifdef CHIHIRO_WORK
593590
// If the Xbe is Chihiro, and we were not launched by SEGABOOT, we need to load SEGABOOT from the Chihiro Media Board rom instead!
594-
if (BootFlags == BOOT_NONE && emulate_system == SYSTEM_CHIHIRO) {
591+
// All checks are absolutely necessary in order to support both "auto select" and forced chihiro mode.
592+
if (BootFlags == BOOT_NONE &&
593+
emulate_system == SYSTEM_CHIHIRO &&
594+
std::filesystem::exists(xbeDirectory / "boot.id")) {
595595

596596
std::string chihiroMediaBoardRom = g_DataFilePath + "/EmuDisk/" + MediaBoardRomFile;
597597
if (!std::filesystem::exists(chihiroMediaBoardRom)) {
@@ -653,7 +653,6 @@ static bool CxbxrKrnlXbeSystemSelector(int BootFlags,
653653
CxbxLaunchNewXbe(chihiroSegaBootNew);
654654
CxbxrShutDown(true);
655655
}
656-
#endif // Chihiro wip block
657656

658657
// Once we have determine which system type to run as, enforce it in future reboots.
659658
if ((BootFlags & BOOT_QUICK_REBOOT) == 0) {
@@ -677,17 +676,11 @@ static bool CxbxrKrnlXbeSystemSelector(int BootFlags,
677676
hardwareModel = HardwareModel::Revision1_6;
678677
}
679678

680-
#ifdef CHIHIRO_WORK
681679
// If this is a Chihiro title, we need to patch the init flags to disable HDD setup
682680
// The Chihiro kernel does this, so we should too!
683681
if (g_bIsChihiro) {
684682
CxbxKrnl_Xbe->m_Header.dwInitFlags.bDontSetupHarddisk = true;
685683
}
686-
#else
687-
if (g_bIsChihiro) {
688-
CxbxrAbort("Emulating Chihiro mode does not work yet. Please use different title to emulate.");
689-
}
690-
#endif
691684

692685
CxbxrKrnlSetupMemorySystem(BootFlags, emulate_system, reserved_systems, blocks_reserved);
693686
return true;
@@ -1412,12 +1405,10 @@ static void CxbxrKrnlInitHacks()
14121405

14131406
EmuInitFS();
14141407

1415-
#ifdef CHIHIRO_WORK
14161408
// If this title is Chihiro, Setup JVS
14171409
if (g_bIsChihiro) {
14181410
JVS_Init();
14191411
}
1420-
#endif
14211412

14221413
EmuX86_Init();
14231414
// Start the event thread

src/gui/WndMain.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,6 +2419,10 @@ DWORD WndMain::CrashMonitorWrapper(LPVOID lpParam)
24192419
static_cast<WndMain*>(pCMD->pWndMain)->m_iIsEmulating--; // Multi-xbe boots usage check
24202420
}
24212421

2422+
if (!static_cast<WndMain*>(pCMD->pWndMain)->m_iIsEmulating) {
2423+
static_cast<WndMain*>(pCMD->pWndMain)->StopEmulation();
2424+
}
2425+
24222426
free(lpParam);
24232427

24242428
return 0;
@@ -2427,7 +2431,6 @@ DWORD WndMain::CrashMonitorWrapper(LPVOID lpParam)
24272431
// monitor for crashes
24282432
void WndMain::CrashMonitor(DWORD dwChildProcID)
24292433
{
2430-
int iBootFlags;
24312434
DWORD dwExitCode = 0;
24322435

24332436
// If we do receive valid process ID, let's do the next step.
@@ -2442,23 +2445,8 @@ void WndMain::CrashMonitor(DWORD dwChildProcID)
24422445

24432446
GetExitCodeProcess(hProcess, &dwExitCode);
24442447
CloseHandle(hProcess);
2445-
2446-
g_EmuShared->GetBootFlags(&iBootFlags);
2447-
2448-
// Check if reboot did occur.
2449-
if (iBootFlags) {
2450-
// Destroy this thread and start a new one
2451-
// since emulation is still running.
2452-
return;
2453-
}
2454-
// Otherwise emulation did stopped or crashed
2455-
// But need to tell GUI that emulation did end.
24562448
}
24572449
}
2458-
2459-
// Crash clean up.
2460-
2461-
StopEmulation();
24622450
}
24632451

24642452
// monitor for Debugger to close then set as "available" (For limit to 1 debugger per Cxbx GUI.)

0 commit comments

Comments
 (0)