diff --git a/Core/HLE/sceCtrl.cpp b/Core/HLE/sceCtrl.cpp index ac85a3f1a8..5874ae2865 100644 --- a/Core/HLE/sceCtrl.cpp +++ b/Core/HLE/sceCtrl.cpp @@ -62,7 +62,6 @@ struct CtrlLatch { ////////////////////////////////////////////////////////////////////////// // STATE BEGIN -static bool ctrlInited = false; static bool analogEnabled = false; static int ctrlLatchBufs = 0; static u32 ctrlOldButtons = 0; @@ -259,13 +258,14 @@ void __CtrlTimerUpdate(u64 userdata, int cyclesLate) void __CtrlInit() { - std::lock_guard guard(ctrlMutex); + ctrlTimer = CoreTiming::RegisterEvent("CtrlSampleTimer", __CtrlTimerUpdate); + __DisplayListenVblank(__CtrlVblank); - if (!ctrlInited) - { - __DisplayListenVblank(__CtrlVblank); - ctrlInited = true; - } + ctrlIdleReset = -1; + ctrlIdleBack = -1; + ctrlCycle = 0; + + std::lock_guard guard(ctrlMutex); ctrlBuf = 1; ctrlBufRead = 0; @@ -282,14 +282,11 @@ void __CtrlInit() for (int i = 0; i < NUM_CTRL_BUFFERS; i++) memcpy(&ctrlBufs[i], &ctrlCurrent, sizeof(_ctrl_data)); +} - ctrlIdleReset = -1; - ctrlIdleBack = -1; - ctrlCycle = 0; - +void __CtrlShutdown() +{ waitingThreads.clear(); - - ctrlTimer = CoreTiming::RegisterEvent("CtrlSampleTimer", __CtrlTimerUpdate); } u32 sceCtrlSetSamplingCycle(u32 cycle) diff --git a/Core/HLE/sceCtrl.h b/Core/HLE/sceCtrl.h index dcb465f305..62dff53bcc 100644 --- a/Core/HLE/sceCtrl.h +++ b/Core/HLE/sceCtrl.h @@ -33,6 +33,7 @@ void Register_sceCtrl(); #define CTRL_RTRIGGER 0x0200 void __CtrlInit(); +void __CtrlShutdown(); void __CtrlButtonDown(u32 buttonBit); void __CtrlButtonUp(u32 buttonBit); diff --git a/Core/HLE/sceImpose.cpp b/Core/HLE/sceImpose.cpp index 93a417a088..4122d1e40b 100644 --- a/Core/HLE/sceImpose.cpp +++ b/Core/HLE/sceImpose.cpp @@ -36,6 +36,11 @@ const int PSP_LANGUAGE_SIMPLIFIED_CHINESE = 11; static u32 iLanguage = PSP_LANGUAGE_ENGLISH; static u32 iButtonValue = 0; +void __ImposeInit() +{ + iLanguage = PSP_LANGUAGE_ENGLISH; + iButtonValue = 0; +} u32 sceImposeGetBatteryIconStatus(u32 chargingPtr, u32 iconStatusPtr) { diff --git a/Core/HLE/sceImpose.h b/Core/HLE/sceImpose.h index 1de2aea93e..86eabedcec 100644 --- a/Core/HLE/sceImpose.h +++ b/Core/HLE/sceImpose.h @@ -18,3 +18,4 @@ #pragma once void Register_sceImpose(); +void __ImposeInit(); diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 941d3a63ef..9f03b26d17 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -84,7 +84,7 @@ const std::string &EmuDebugOutput() { typedef u32 (*DeferredAction)(SceUID id, int param); DeferredAction defAction = 0; -u32 defParam; +u32 defParam = 0; #define SCE_STM_FDIR 0x1000 #define SCE_STM_FREG 0x2000 @@ -154,6 +154,8 @@ public: void __IoInit() { INFO_LOG(HLE, "Starting up I/O..."); + MemoryStick_SetFatState(PSP_FAT_MEMORYSTICK_STATE_ASSIGNED); + #ifdef _WIN32 char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; @@ -192,6 +194,8 @@ void __IoInit() { } void __IoShutdown() { + defAction = 0; + defParam = 0; } u32 sceIoAssign(const char *aliasname, const char *physname, const char *devname, u32 flag) { diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index d4a34dc894..3197c11107 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -53,6 +53,8 @@ #include "sceUmd.h" #include "sceSsl.h" #include "sceSas.h" +#include "sceImpose.h" +#include "sceUsb.h" #include "../Util/PPGeDraw.h" @@ -78,6 +80,10 @@ void __KernelInit() __KernelMemoryInit(); __KernelThreadingInit(); __KernelMutexInit(); + __KernelSemaInit(); + __KernelAlarmInit(); + __KernelEventFlagInit(); + __KernelMbxInit(); __IoInit(); __AudioInit(); __SasInit(); @@ -89,6 +95,8 @@ void __KernelInit() __UmdInit(); __CtrlInit(); __SslInit(); + __ImposeInit(); + __UsbInit(); // "Internal" PSP libraries __PPGeInit(); @@ -110,13 +118,15 @@ void __KernelShutdown() __PPGeShutdown(); + __CtrlShutdown(); + __UtilityShutdown(); __GeShutdown(); __SasShutdown(); __AudioShutdown(); __IoShutdown(); __InterruptsShutdown(); - __KernelThreadingShutdown(); __KernelMutexShutdown(); + __KernelThreadingShutdown(); __KernelMemoryShutdown(); CoreTiming::ClearPendingEvents(); diff --git a/Core/HLE/sceKernelAlarm.cpp b/Core/HLE/sceKernelAlarm.cpp index 984c558e04..4e378b2a49 100644 --- a/Core/HLE/sceKernelAlarm.cpp +++ b/Core/HLE/sceKernelAlarm.cpp @@ -78,17 +78,7 @@ public: Alarm *alarm; }; -bool alarmInitComplete = false; -int alarmTimer = 0; - -void __KernelTriggerAlarm(u64 userdata, int cyclesLate); - -void __KernelAlarmInit() -{ - alarmTimer = CoreTiming::RegisterEvent("Alarm", __KernelTriggerAlarm); - - alarmInitComplete = true; -} +static int alarmTimer = 0; void __KernelTriggerAlarm(u64 userdata, int cyclesLate) { @@ -100,6 +90,11 @@ void __KernelTriggerAlarm(u64 userdata, int cyclesLate) __TriggerInterrupt(PSP_INTR_IMMEDIATE, PSP_SYSTIMER0_INTR, uid); } +void __KernelAlarmInit() +{ + alarmTimer = CoreTiming::RegisterEvent("Alarm", __KernelTriggerAlarm); +} + void __KernelScheduleAlarm(Alarm *alarm, u64 ticks) { alarm->alm.schedule = (CoreTiming::GetTicks() + ticks) / (u64) CoreTiming::GetClockFrequencyMHz(); @@ -108,9 +103,6 @@ void __KernelScheduleAlarm(Alarm *alarm, u64 ticks) SceUID __KernelSetAlarm(u64 ticks, u32 handlerPtr, u32 commonPtr) { - if (!alarmInitComplete) - __KernelAlarmInit(); - if (!Memory::IsValidAddress(handlerPtr)) return SCE_KERNEL_ERROR_ILLEGAL_ADDR; diff --git a/Core/HLE/sceKernelAlarm.h b/Core/HLE/sceKernelAlarm.h index f430a20da9..09dd2e2f82 100644 --- a/Core/HLE/sceKernelAlarm.h +++ b/Core/HLE/sceKernelAlarm.h @@ -20,4 +20,6 @@ SceUID sceKernelSetAlarm(SceUInt clock, u32 handlerPtr, u32 commonPtr); SceUID sceKernelSetSysClockAlarm(u32 sysClockPtr, u32 handlerPtr, u32 commonPtr); int sceKernelCancelAlarm(SceUID uid); -int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr); \ No newline at end of file +int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr); + +void __KernelAlarmInit(); diff --git a/Core/HLE/sceKernelEventFlag.cpp b/Core/HLE/sceKernelEventFlag.cpp index ed237a1e25..a28c06c0d6 100644 --- a/Core/HLE/sceKernelEventFlag.cpp +++ b/Core/HLE/sceKernelEventFlag.cpp @@ -90,13 +90,11 @@ enum PspEventFlagWaitTypes PSP_EVENT_WAITKNOWN = PSP_EVENT_WAITCLEAR | PSP_EVENT_WAITCLEARALL | PSP_EVENT_WAITOR, }; -bool eventFlagInitComplete = false; int eventFlagWaitTimer = 0; void __KernelEventFlagInit() { eventFlagWaitTimer = CoreTiming::RegisterEvent("EventFlagTimeout", &__KernelEventFlagTimeout); - eventFlagInitComplete = true; } bool __KernelEventFlagMatches(u32 *pattern, u32 bits, u8 wait, u32 outAddr) @@ -168,9 +166,6 @@ bool __KernelClearEventFlagThreads(EventFlag *e, int reason) //SceUID sceKernelCreateEventFlag(const char *name, int attr, int bits, SceKernelEventFlagOptParam *opt); int sceKernelCreateEventFlag(const char *name, u32 flag_attr, u32 flag_initPattern, u32 optPtr) { - if (!eventFlagInitComplete) - __KernelEventFlagInit(); - if (!name) { WARN_LOG(HLE, "%08x=sceKernelCreateEventFlag(): invalid name", SCE_KERNEL_ERROR_ERROR); diff --git a/Core/HLE/sceKernelEventFlag.h b/Core/HLE/sceKernelEventFlag.h index b47b43c53b..4243b8d897 100644 --- a/Core/HLE/sceKernelEventFlag.h +++ b/Core/HLE/sceKernelEventFlag.h @@ -26,3 +26,5 @@ int sceKernelWaitEventFlagCB(SceUID id, u32 bits, u32 wait, u32 outBitsPtr, u32 int sceKernelPollEventFlag(SceUID id, u32 bits, u32 wait, u32 outBitsPtr, u32 timeoutPtr); u32 sceKernelReferEventFlagStatus(SceUID id, u32 statusPtr); u32 sceKernelCancelEventFlag(SceUID uid, u32 pattern, u32 numWaitThreadsPtr); + +void __KernelEventFlagInit(); diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index 3ee53f9e77..bc00c82254 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -33,35 +33,9 @@ struct Interrupt PSPInterrupt intno; }; -// Yeah, this bit is a bit silly. -static int interruptsEnabled = 1; -static bool inInterrupt; - - -void __InterruptsInit() -{ - interruptsEnabled = 1; -} - -void __InterruptsShutdown() -{ -} - -void __DisableInterrupts() -{ - interruptsEnabled = 0; -} - -void __EnableInterrupts() -{ - interruptsEnabled = 1; -} - -bool __InterruptsEnabled() -{ - return interruptsEnabled != 0; -} - +void __DisableInterrupts(); +void __EnableInterrupts(); +bool __InterruptsEnabled(); // InterruptsManager ////////////////////////////////////////////////////////////////////////// @@ -116,18 +90,6 @@ void sceKernelCpuResumeIntrWithSync(u32 enable) sceKernelCpuResumeIntr(enable); } - - -bool __IsInInterrupt() -{ - return inInterrupt; -} - -bool __CanExecuteInterrupt() -{ - return !inInterrupt; -} - class IntrHandler { public: void add(int subIntrNum, SubIntrHandler *handler) @@ -154,6 +116,13 @@ public: return 0; // what to do, what to do... } + void clear() + { + std::map::iterator it, end; + for (it = subIntrHandlers.begin(), end = subIntrHandlers.end(); it != end; ++it) + delete it->second; + subIntrHandlers.clear(); + } void queueUp(int subintr) { @@ -184,17 +153,9 @@ private: class InterruptState { public: - void save() - { - insideInterrupt = __IsInInterrupt(); - __KernelSaveContext(&savedCpu); - } - - void restore() - { - ::inInterrupt = insideInterrupt; - __KernelLoadContext(&savedCpu); - } + void save(); + void restore(); + void clear(); bool insideInterrupt; ThreadContext savedCpu; @@ -208,6 +169,66 @@ InterruptState intState; IntrHandler intrHandlers[PSP_NUMBER_INTERRUPTS]; std::list pendingInterrupts; +// Yeah, this bit is a bit silly. +static int interruptsEnabled = 1; +static bool inInterrupt; + + +void __InterruptsInit() +{ + interruptsEnabled = 1; + inInterrupt = false; + intState.clear(); +} + +void __InterruptsShutdown() +{ + for (int i = 0; i < PSP_NUMBER_INTERRUPTS; ++i) + intrHandlers[i].clear(); + pendingInterrupts.clear(); +} + +void __DisableInterrupts() +{ + interruptsEnabled = 0; +} + +void __EnableInterrupts() +{ + interruptsEnabled = 1; +} + +bool __InterruptsEnabled() +{ + return interruptsEnabled != 0; +} + +bool __IsInInterrupt() +{ + return inInterrupt; +} + +bool __CanExecuteInterrupt() +{ + return !inInterrupt; +} + +void InterruptState::save() +{ + insideInterrupt = __IsInInterrupt(); + __KernelSaveContext(&savedCpu); +} + +void InterruptState::restore() +{ + ::inInterrupt = insideInterrupt; + __KernelLoadContext(&savedCpu); +} + +void InterruptState::clear() +{ + insideInterrupt = false; +} // http://forums.ps2dev.org/viewtopic.php?t=5687 diff --git a/Core/HLE/sceKernelMbx.cpp b/Core/HLE/sceKernelMbx.cpp index bcd3b74d84..c8c758a215 100644 --- a/Core/HLE/sceKernelMbx.cpp +++ b/Core/HLE/sceKernelMbx.cpp @@ -30,8 +30,7 @@ const int PSP_MBX_ERROR_DUPLICATE_MSG = 0x800201C9; typedef std::pair MbxWaitingThread; void __KernelMbxTimeout(u64 userdata, int cyclesLate); -bool mbxInitComplete = false; -int mbxWaitTimer = 0; +static int mbxWaitTimer = 0; struct NativeMbx { @@ -162,8 +161,6 @@ struct Mbx : public KernelObject void __KernelMbxInit() { mbxWaitTimer = CoreTiming::RegisterEvent("MbxTimeout", &__KernelMbxTimeout); - - mbxInitComplete = true; } bool __KernelUnlockMbxForThread(Mbx *m, MbxWaitingThread &th, u32 &error, int result, bool &wokeThreads) @@ -263,9 +260,6 @@ std::vector::iterator __KernelMbxFindPriority(std::vector waitingThreads; }; -bool mutexInitComplete = false; -int mutexWaitTimer = 0; -int lwMutexWaitTimer = 0; +static int mutexWaitTimer = 0; +static int lwMutexWaitTimer = 0; // Thread -> Mutex locks for thread end. typedef std::multimap MutexMap; -MutexMap mutexHeldLocks; +static MutexMap mutexHeldLocks; void __KernelMutexInit() { mutexWaitTimer = CoreTiming::RegisterEvent("MutexTimeout", &__KernelMutexTimeout); lwMutexWaitTimer = CoreTiming::RegisterEvent("LwMutexTimeout", &__KernelLwMutexTimeout); - // TODO: Install on first mutex (if it's slow?) __KernelListenThreadEnd(&__KernelMutexThreadEnd); - - mutexInitComplete = true; - mutexWaitTimer = 0; - lwMutexWaitTimer = 0; } void __KernelMutexShutdown() @@ -191,9 +185,6 @@ std::vector::iterator __KernelMutexFindPriority(std::vector &wai int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optionsPtr) { - if (!mutexInitComplete) - __KernelMutexInit(); - if (!name) { WARN_LOG(HLE, "%08x=sceKernelCreateMutex(): invalid name", SCE_KERNEL_ERROR_ERROR); @@ -507,9 +498,6 @@ int sceKernelUnlockMutex(SceUID id, int count) int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int initialCount, u32 optionsPtr) { - if (!mutexInitComplete) - __KernelMutexInit(); - if (!name) { WARN_LOG(HLE, "%08x=sceKernelCreateLwMutex(): invalid name", SCE_KERNEL_ERROR_ERROR); diff --git a/Core/HLE/sceKernelSemaphore.cpp b/Core/HLE/sceKernelSemaphore.cpp index 5b9bdd3d7a..39dc209928 100644 --- a/Core/HLE/sceKernelSemaphore.cpp +++ b/Core/HLE/sceKernelSemaphore.cpp @@ -61,13 +61,11 @@ struct Semaphore : public KernelObject std::vector waitingThreads; }; -bool semaInitComplete = false; -int semaWaitTimer = 0; +static int semaWaitTimer = 0; void __KernelSemaInit() { semaWaitTimer = CoreTiming::RegisterEvent("SemaphoreTimeout", &__KernelSemaTimeout); - semaInitComplete = true; } // Returns whether the thread should be removed. @@ -173,9 +171,6 @@ int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr) //SceUID sceKernelCreateSema(const char *name, SceUInt attr, int initVal, int maxVal, SceKernelSemaOptParam *option); int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 optionPtr) { - if (!semaInitComplete) - __KernelSemaInit(); - if (!name) { WARN_LOG(HLE, "%08x=sceKernelCreateSema(): invalid name", SCE_KERNEL_ERROR_ERROR); diff --git a/Core/HLE/sceKernelSemaphore.h b/Core/HLE/sceKernelSemaphore.h index 32150c6307..9a8b9f2640 100644 --- a/Core/HLE/sceKernelSemaphore.h +++ b/Core/HLE/sceKernelSemaphore.h @@ -27,3 +27,5 @@ int sceKernelWaitSema(SceUID semaid, int signal, u32 timeoutPtr); int sceKernelWaitSemaCB(SceUID semaid, int signal, u32 timeoutPtr); void __KernelSemaTimeout(u64 userdata, int cycleslate); + +void __KernelSemaInit(); diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 6807fd92d2..8d03a17f8a 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -162,7 +162,50 @@ struct ThreadWaitInfo { u32 timeoutPtr; }; -class ActionAfterMipsCall; +// Owns outstanding MIPS calls and provides a way to get them by ID. +// TODO: MipsCall structs are kinda big, try to cut down on the copying by owning pointers instead. +class MipsCallManager { +public: + MipsCallManager() : idGen_(0) {} + int add(MipsCall *call) { + int id = genId(); + calls_.insert(std::pair(id, call)); + return id; + } + MipsCall *get(int id) { + return calls_[id]; + } + MipsCall *pop(int id) { + MipsCall *temp = calls_[id]; + calls_.erase(id); + return temp; + } + void clear() { + calls_.clear(); + idGen_ = 0; + } + +private: + int genId() { return ++idGen_; } + std::map calls_; + int idGen_; +}; + +class ActionAfterMipsCall : public Action +{ +public: + virtual void run(); + Thread *thread; + + // Saved thread state + int status; + WaitType waitType; + int waitID; + ThreadWaitInfo waitInfo; + bool isProcessingCallbacks; + + Action *chainedAction; +}; class Thread : public KernelObject { @@ -276,8 +319,6 @@ public: void __KernelExecuteMipsCallOnCurrentThread(int callId, bool reschedAfter); -int g_inCbCount = 0; - Thread *__KernelCreateThread(SceUID &id, SceUID moduleID, const char *name, u32 entryPoint, u32 priority, int stacksize, u32 attr); void __KernelResetThread(Thread *t); void __KernelCancelWakeup(SceUID threadID); @@ -286,6 +327,7 @@ bool __KernelCheckThreadCallbacks(Thread *thread, bool force); ////////////////////////////////////////////////////////////////////////// //STATE BEGIN ////////////////////////////////////////////////////////////////////////// +int g_inCbCount = 0; Thread *currentThread; u32 idleThreadHackAddr; u32 threadReturnHackAddr; @@ -300,6 +342,7 @@ int eventScheduledWakeup; bool dispatchEnabled = true; +MipsCallManager mipsCalls; // This seems nasty SceUID curModule; @@ -435,10 +478,13 @@ void __KernelThreadingShutdown() { kernelMemory.Free(threadReturnHackAddr); threadqueue.clear(); + threadEndListeners.clear(); + mipsCalls.clear(); threadReturnHackAddr = 0; cbReturnHackAddr = 0; currentThread = 0; intReturnHackAddr = 0; + curModule = 0; } const char *__KernelGetThreadName(SceUID threadID) @@ -1568,50 +1614,6 @@ void sceKernelReferCallbackStatus() } } -// Owns outstanding MIPS calls and provides a way to get them by ID. -// TODO: MipsCall structs are kinda big, try to cut down on the copying by owning pointers instead. -class MipsCallManager { -public: - MipsCallManager() : idGen_(0) {} - int add(MipsCall *call) { - int id = genId(); - calls_.insert(std::pair(id, call)); - return id; - } - MipsCall *get(int id) { - return calls_[id]; - } - MipsCall *pop(int id) { - MipsCall *temp = calls_[id]; - calls_.erase(id); - return temp; - } - -private: - int genId() { return ++idGen_; } - std::map calls_; - int idGen_; -}; - -MipsCallManager mipsCalls; - - -class ActionAfterMipsCall : public Action -{ -public: - virtual void run(); - Thread *thread; - - // Saved thread state - int status; - WaitType waitType; - int waitID; - ThreadWaitInfo waitInfo; - bool isProcessingCallbacks; - - Action *chainedAction; -}; - void ActionAfterMipsCall::run() { thread->nt.status = status; thread->nt.waitType = waitType; @@ -1625,7 +1627,6 @@ void ActionAfterMipsCall::run() { } } - ActionAfterMipsCall *Thread::getRunningCallbackAction() { if (this == currentThread && g_inCbCount > 0) diff --git a/Core/HLE/scePower.cpp b/Core/HLE/scePower.cpp index bfe1943bc1..c6b0fecb7d 100644 --- a/Core/HLE/scePower.cpp +++ b/Core/HLE/scePower.cpp @@ -22,16 +22,15 @@ #include "scePower.h" #include "sceKernelThread.h" -static bool volatileMemLocked; - const int POWER_CB_AUTO = -1; - const int numberOfCBPowerSlots = 16; -static int powerCbSlots[numberOfCBPowerSlots]; +static bool volatileMemLocked; +static int powerCbSlots[numberOfCBPowerSlots]; void __PowerInit() { memset(powerCbSlots, 0, sizeof(powerCbSlots)); + volatileMemLocked = false; } int scePowerGetBatteryLifePercent() { diff --git a/Core/HLE/sceUmd.cpp b/Core/HLE/sceUmd.cpp index a4fd3b8b11..3e358d36a3 100644 --- a/Core/HLE/sceUmd.cpp +++ b/Core/HLE/sceUmd.cpp @@ -47,8 +47,11 @@ struct PspUmdInfo { u32 type; }; +void __UmdStatTimeout(u64 userdata, int cyclesLate); -void __UmdInit() { +void __UmdInit() +{ + umdStatTimer = CoreTiming::RegisterEvent("UmdTimeout", &__UmdStatTimeout); umdActivated = 1; umdStatus = 0; umdErrorStat = 0; @@ -214,9 +217,6 @@ void __UmdStatTimeout(u64 userdata, int cyclesLate) void __UmdWaitStat(u32 timeout) { - if (umdStatTimer == 0) - umdStatTimer = CoreTiming::RegisterEvent("UmdTimeout", &__UmdStatTimeout); - // This happens to be how the hardware seems to time things. if (timeout <= 4) timeout = 15; diff --git a/Core/HLE/sceUsb.cpp b/Core/HLE/sceUsb.cpp index faec5397a9..1d1ebc2189 100644 --- a/Core/HLE/sceUsb.cpp +++ b/Core/HLE/sceUsb.cpp @@ -22,6 +22,11 @@ bool usbActivated = false; +void __UsbInit() +{ + usbActivated = false; +} + u32 sceUsbActivate() { ERROR_LOG(HLE, "UNIMPL sceUsbActivate"); usbActivated = true; diff --git a/Core/HLE/sceUsb.h b/Core/HLE/sceUsb.h index 009f44ec96..d521a0a9da 100644 --- a/Core/HLE/sceUsb.h +++ b/Core/HLE/sceUsb.h @@ -18,3 +18,5 @@ #pragma once void Register_sceUsb(); + +void __UsbInit(); diff --git a/Core/HLE/sceUtility.cpp b/Core/HLE/sceUtility.cpp index 3155748cf3..b66f705066 100644 --- a/Core/HLE/sceUtility.cpp +++ b/Core/HLE/sceUtility.cpp @@ -39,6 +39,14 @@ void __UtilityInit() SavedataParam::Init(); } +void __UtilityShutdown() +{ + saveDialog.Shutdown(); + msgDialog.Shutdown(); + oskDialog.Shutdown(); + netDialog.Shutdown(); +} + int sceUtilitySavedataInitStart(u32 paramAddr) { DEBUG_LOG(HLE,"sceUtilitySavedataInitStart(%08x)", paramAddr); diff --git a/Core/HLE/sceUtility.h b/Core/HLE/sceUtility.h index 3eefa42b8e..ba85cd06c9 100644 --- a/Core/HLE/sceUtility.h +++ b/Core/HLE/sceUtility.h @@ -18,5 +18,6 @@ #pragma once void __UtilityInit(); +void __UtilityShutdown(); void Register_sceUtility(); diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 73dc9e129b..477b2dd4f7 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -52,7 +52,9 @@ MIPSState::~MIPSState() void MIPSState::Reset() { - if (!MIPSComp::jit && PSP_CoreParameter().cpuCore == CPU_JIT) + if (MIPSComp::jit) + delete MIPSComp::jit; + if (PSP_CoreParameter().cpuCore == CPU_JIT) MIPSComp::jit = new MIPSComp::Jit(this); memset(r, 0, sizeof(r)); diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index b5bab73b78..40c44a7fd2 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -191,6 +191,8 @@ GLES_GPU::~GLES_GPU() delete (*iter); } vfbs_.clear(); + + delete flushBeforeCommand; } void GLES_GPU::InitClear() diff --git a/GPU/Null/NullGpu.cpp b/GPU/Null/NullGpu.cpp index 3dd5228a02..8502418850 100644 --- a/GPU/Null/NullGpu.cpp +++ b/GPU/Null/NullGpu.cpp @@ -46,6 +46,17 @@ static bool finished; static int dlIdGenerator = 1; +NullGPU::NullGPU() +{ + interruptsEnabled_ = true; + dlIdGenerator = 1; +} + +NullGPU::~NullGPU() +{ + dlQueue.clear(); +} + bool NullGPU::ProcessDLQueue() { std::vector::iterator iter = dlQueue.begin(); diff --git a/GPU/Null/NullGpu.h b/GPU/Null/NullGpu.h index 93e9de9488..199ad07e04 100644 --- a/GPU/Null/NullGpu.h +++ b/GPU/Null/NullGpu.h @@ -24,7 +24,8 @@ class ShaderManager; class NullGPU : public GPUInterface { public: - NullGPU() : interruptsEnabled_(true) {} + NullGPU(); + ~NullGPU(); virtual void InitClear() {} virtual u32 EnqueueList(u32 listpc, u32 stall); virtual void UpdateStall(int listid, u32 newstall); diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 1309ebddb3..debfc928bd 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -648,11 +648,12 @@ namespace MainWindow CHECKITEM(ID_OPTIONS_HARDWARETRANSFORM, g_Config.bHardwareTransform); CHECKITEM(ID_OPTIONS_FASTMEMORY, g_Config.bFastMemory); - BOOL enable = !Core_IsStepping(); - EnableMenuItem(menu,ID_EMULATION_RUN,enable); - EnableMenuItem(menu,ID_EMULATION_PAUSE,!enable); + UINT enable = !Core_IsStepping() ? MF_GRAYED : MF_ENABLED; + EnableMenuItem(menu,ID_EMULATION_RUN, g_State.bEmuThreadStarted ? enable : MF_GRAYED); + EnableMenuItem(menu,ID_EMULATION_PAUSE, g_State.bEmuThreadStarted ? !enable : MF_GRAYED); + EnableMenuItem(menu,ID_EMULATION_RESET, g_State.bEmuThreadStarted ? MF_ENABLED : MF_GRAYED); - enable = g_State.bEmuThreadStarted; + enable = g_State.bEmuThreadStarted ? MF_GRAYED : MF_ENABLED; EnableMenuItem(menu,ID_FILE_LOAD,enable); EnableMenuItem(menu,ID_CPU_DYNAREC,enable); EnableMenuItem(menu,ID_CPU_INTERPRETER,enable); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 64c8282667..40f6f0e24f 100644 Binary files a/Windows/ppsspp.rc and b/Windows/ppsspp.rc differ