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 2 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
23 changes: 20 additions & 3 deletions Core/HLE/sceUmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include "Core/FileSystems/MetaFileSystem.h"
#include "Core/FileSystems/ISOFileSystem.h"
#include "Core/FileSystems/VirtualDiscFileSystem.h"
#include "base/timeutil.h"
#ifdef USING_WIN_UI
#include "Windows/MainWindowMenu.h"
#endif

const u64 MICRO_DELAY_ACTIVATE = 4000;

Expand All @@ -51,6 +55,7 @@ static std::vector<SceUID> umdWaitingThreads;
static std::map<SceUID, u64> umdPausedWaits;

bool UMDReplacePermit = false;
bool UMD_insterted = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename UMDInserted , simple spelling mistake :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


struct PspUmdInfo {
u32_le size;
Expand Down Expand Up @@ -225,8 +230,12 @@ void __UmdEndCallback(SceUID threadID, SceUID prevCallbackId)

static int sceUmdCheckMedium()
{
DEBUG_LOG(SCEIO, "1=sceUmdCheckMedium()");
return 1; //non-zero: disc in drive
if (UMD_insterted) {
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 +504,9 @@ void __UmdReplace(std::string filepath) {
}
}
delete currentUMD;

UMD_insterted = false;
sleep_ms(200); // Wait sceUmdCheckMedium call
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this isn't very nice .. on the other hand, this will probably be pretty reliable as long as __UmdReplace is not called from the emulator thread. I fear though that it may be, on Android? Got to check to be sure though.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better solution may be to schedule an event (you know, RegisterEvent and so on) that will set UMDInserted back after a little bit.

UMD_insterted = true;
// 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 +521,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();
}