Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Akaya Akashiya Ayakashi" umd switch #9245

Merged
merged 6 commits into from
Jan 29, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions Core/HLE/sceUmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include "Core/FileSystems/MetaFileSystem.h"
#include "Core/FileSystems/ISOFileSystem.h"
#include "Core/FileSystems/VirtualDiscFileSystem.h"
#ifdef USING_WIN_UI
#include "Windows/MainWindowMenu.h"
#endif

const u64 MICRO_DELAY_ACTIVATE = 4000;

Expand All @@ -47,10 +50,12 @@ static u32 umdErrorStat = 0;
static int driveCBId = 0;
static int umdStatTimeoutEvent = -1;
static int umdStatChangeEvent = -1;
static int umdInsertChangeEvent = -1;
static std::vector<SceUID> umdWaitingThreads;
static std::map<SceUID, u64> umdPausedWaits;

bool UMDReplacePermit = false;
bool UMDInserted = true;

struct PspUmdInfo {
u32_le size;
Expand All @@ -59,13 +64,15 @@ struct PspUmdInfo {

void __UmdStatTimeout(u64 userdata, int cyclesLate);
void __UmdStatChange(u64 userdata, int cyclesLate);
void __UmdInsertChange(u64 userdata, int cyclesLate);
void __UmdBeginCallback(SceUID threadID, SceUID prevCallbackId);
void __UmdEndCallback(SceUID threadID, SceUID prevCallbackId);

void __UmdInit()
{
umdStatTimeoutEvent = CoreTiming::RegisterEvent("UmdTimeout", __UmdStatTimeout);
umdStatChangeEvent = CoreTiming::RegisterEvent("UmdChange", __UmdStatChange);
umdInsertChangeEvent = CoreTiming::RegisterEvent("UmdInsertChange", __UmdInsertChange);
umdActivated = 1;
umdStatus = 0;
umdErrorStat = 0;
Expand Down Expand Up @@ -108,6 +115,11 @@ static u8 __KernelUmdGetState()
return state;
}

void __UmdInsertChange(u64 userdata, int cyclesLate)
{
UMDInserted = true;
}

void __UmdStatChange(u64 userdata, int cyclesLate)
{
// TODO: Why not a bool anyway?
Expand Down Expand Up @@ -225,8 +237,12 @@ void __UmdEndCallback(SceUID threadID, SceUID prevCallbackId)

static int sceUmdCheckMedium()
{
DEBUG_LOG(SCEIO, "1=sceUmdCheckMedium()");
return 1; //non-zero: disc in drive
if (UMDInserted) {
DEBUG_LOG(SCEIO, "1=sceUmdCheckMedium()");
return 1; //non-zero: disc in drive
}
DEBUG_LOG(SCEIO, "0=sceUmdCheckMedium()");
return 0;
}

static u32 sceUmdGetDiscInfo(u32 infoAddr)
Expand Down Expand Up @@ -495,7 +511,8 @@ void __UmdReplace(std::string filepath) {
}
}
delete currentUMD;

UMDInserted = false;
CoreTiming::ScheduleEvent(usToCycles(200*1000), umdInsertChangeEvent, 0); // Wait sceUmdCheckMedium call
// TODO Is this always correct if UMD was not activated?
u32 notifyArg = PSP_UMD_PRESENT | PSP_UMD_READABLE | PSP_UMD_CHANGED;
if (driveCBId != -1)
Expand All @@ -510,13 +527,19 @@ static u32 sceUmdReplaceProhibit()
{
UMDReplacePermit = false;
DEBUG_LOG(SCEIO,"sceUmdReplaceProhibit()");
#ifdef USING_WIN_UI
MainWindow::ChangeMenu();
#endif
return 0;
}

static u32 sceUmdReplacePermit()
{
UMDReplacePermit = true;
DEBUG_LOG(SCEIO,"sceUmdReplacePermit()");
#ifdef USING_WIN_UI
MainWindow::ChangeMenu();
#endif
return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions Windows/MainWindowMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,4 +1258,8 @@ namespace MainWindow {
}
return FALSE;
}

void ChangeMenu() {
SetIngameMenuItemStates(GetMenu(GetHWND()), UISTATE_INGAME);
}
}
1 change: 1 addition & 0 deletions Windows/MainWindowMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ namespace MainWindow {
void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false);
void BrowseAndBootDone();
void setTexScalingMultiplier(int level);
void ChangeMenu();
}