WM_CREATE: call CpuCreateCriticalSection() instead of CpuInitialize()

This commit is contained in:
tomcw 2022-02-12 19:11:34 +00:00
parent 3fe06faf65
commit b519031de4
4 changed files with 11 additions and 11 deletions

View File

@ -636,6 +636,7 @@ DWORD CpuExecute(const DWORD uCycles, const bool bVideoUpdate)
// Called by:
// . CpuInitialize()
// . SY6522.Reset()
// . FrameCreateWindow() -> WM_CREATE
void CpuCreateCriticalSection(void)
{
if (!g_bCritSectionValid)
@ -648,15 +649,12 @@ void CpuCreateCriticalSection(void)
//===========================================================================
// Called from RepeatInitialization():
// 1) FrameCreateWindow() -> WM_CREATE
// - done to init g_CriticalSection
// - but can't call CpuReset() as mem == NULL
// 2) MemInitialize() -> MemReset()
void CpuInitialize(bool reset)
// . MemInitialize() -> MemReset()
void CpuInitialize(void)
{
regs.a = regs.x = regs.y = 0xFF;
regs.sp = 0x01FF;
if (reset)
CpuReset();
CpuCreateCriticalSection();
@ -683,6 +681,8 @@ void CpuDestroy()
void CpuReset()
{
_ASSERT(mem != NULL);
// 7 cycles
regs.ps = (regs.ps | AF_INTERRUPT) & ~AF_DECIMAL;
regs.pc = *(WORD*)(mem + 0xFFFC);

View File

@ -33,7 +33,7 @@ void CpuCalcCycles(ULONG nExecutedCycles);
DWORD CpuExecute(const DWORD uCycles, const bool bVideoUpdate);
ULONG CpuGetCyclesThisVideoFrame(ULONG nExecutedCycles);
void CpuCreateCriticalSection(void);
void CpuInitialize(bool reset);
void CpuInitialize(void);
void CpuSetupBenchmark ();
void CpuIrqReset();
void CpuIrqAssert(eIRQSRC Device);

View File

@ -1926,7 +1926,7 @@ void MemReset()
// INITIALIZE & RESET THE CPU
// . Do this after ROM has been copied back to mem[], so that PC is correctly init'ed from 6502's reset vector
CpuInitialize(true);
CpuInitialize();
//Sets Caps Lock = false (Pravets 8A/C only)
z80_reset(); // NB. Also called above in CpuInitialize()

View File

@ -1001,8 +1001,8 @@ LRESULT Win32Frame::WndProc(
DIMouse::DirectInputInit(window);
LogFileOutput("WM_CREATE: DIMouse::DirectInputInit()\n");
CpuInitialize(false); // NB. Creates CriticalSection that's needed by MB_Initialize()
LogFileOutput("WM_CREATE: CpuInitialize()\n");
CpuCreateCriticalSection(); // NB. Creates CriticalSection that's needed by MB_Initialize() -- required on a VM restart
LogFileOutput("WM_CREATE: CpuCreateCriticalSection()\n");
MB_Initialize();
LogFileOutput("WM_CREATE: MB_Initialize()\n");