{"action":"created","issue":{"url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/1854","labels_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/1854/labels{/name}","comments_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/1854/comments","events_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/1854/events","html_url":"https://github.com/dolphin-emu/dolphin/pull/1854","id":53779233,"number":1854,"title":"DVDInterface: Read disc after delay, not before","user":{"login":"JosJuice","id":6716818,"avatar_url":"https://avatars.githubusercontent.com/u/6716818?v=3","gravatar_id":"","url":"https://api.github.com/users/JosJuice","html_url":"https://github.com/JosJuice","followers_url":"https://api.github.com/users/JosJuice/followers","following_url":"https://api.github.com/users/JosJuice/following{/other_user}","gists_url":"https://api.github.com/users/JosJuice/gists{/gist_id}","starred_url":"https://api.github.com/users/JosJuice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosJuice/subscriptions","organizations_url":"https://api.github.com/users/JosJuice/orgs","repos_url":"https://api.github.com/users/JosJuice/repos","events_url":"https://api.github.com/users/JosJuice/events{/privacy}","received_events_url":"https://api.github.com/users/JosJuice/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-01-08T17:47:51Z","updated_at":"2015-02-05T14:16:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/1854","html_url":"https://github.com/dolphin-emu/dolphin/pull/1854","diff_url":"https://github.com/dolphin-emu/dolphin/pull/1854.diff","patch_url":"https://github.com/dolphin-emu/dolphin/pull/1854.patch"},"body":"DVDInterface behavior before 4.0-4222:\r\n* Receive and parse command\r\n* Wait for a while to simulate loading times\r\n* Read data from disc image and copy to emulator memory\r\n* Reply to command\r\n\r\nDVDInterface behavior starting with 4.0-4222:\r\n* Receive and parse command\r\n* Read data from disc image and copy to emulator memory\r\n* Wait for a while to simulate loading times\r\n* Reply to command\r\n\r\nThe former is obviously more accurate, because a real console isn't able to copy all the data to RAM before it has finished reading it from the disc. I changed it in order to not make the code unnecessarily complicated when adding a few things... and games shouldn't be reading the memory that is being copied to, right? Unfortunately, Resident Evil 3 does exactly that, and plays incorrect audio starting with 4.0-2222: https://code.google.com/p/dolphin-emu/issues/detail?id=8026\r\n\r\nThe main obstacle to reverting the order things happen in is that WII_IPC_HLE only can schedule a \"reply to command\" event, not arbitrary things like \"read disc data and reply to command\" that we would need. Because of this, WII_IPC_HLE_Device_DI::IOCtl now returns false and lets DVDInterface::ExecuteCommand schedule an event instead. A second obstacle is that the scheduled event needs to know what data to read. Since DVDInterface now supports WII_IPC_HLE_Device_DI, we can't just read the hardware registers like before 4.0-4222. We can't use pointers in the event userdata either, because it would break savestates. The solution I used is a deque, where a function looks up commands based on an ID that is passed as userdata.\r\n\r\nMost of this solution is actually based on my plans for making a separate thread for disc IO. That has additional reasons for not letting WII_IPC_HLE schedule reads, mainly that it would be nice to be able to finish reads right after the disc IO thread finishes reading from the disc image, but I think this solution is OK for the current requirements too. The good thing is that most of the code in this PR can be used without any change when/if a disc IO thread is made, instead of having to write something similar again.\r\n\r\nBecause this touches WII_IPC_HLE timing, chances are that it will break stuff."},"comment":{"url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/comments/73052183","html_url":"https://github.com/dolphin-emu/dolphin/pull/1854#issuecomment-73052183","issue_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/1854","id":73052183,"user":{"login":"JosJuice","id":6716818,"avatar_url":"https://avatars.githubusercontent.com/u/6716818?v=3","gravatar_id":"","url":"https://api.github.com/users/JosJuice","html_url":"https://github.com/JosJuice","followers_url":"https://api.github.com/users/JosJuice/followers","following_url":"https://api.github.com/users/JosJuice/following{/other_user}","gists_url":"https://api.github.com/users/JosJuice/gists{/gist_id}","starred_url":"https://api.github.com/users/JosJuice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosJuice/subscriptions","organizations_url":"https://api.github.com/users/JosJuice/orgs","repos_url":"https://api.github.com/users/JosJuice/repos","events_url":"https://api.github.com/users/JosJuice/events{/privacy}","received_events_url":"https://api.github.com/users/JosJuice/received_events","type":"User","site_admin":false},"created_at":"2015-02-05T14:16:14Z","updated_at":"2015-02-05T14:16:14Z","body":"Everything should hopefully be fixed now."}}