zaksabeast / DreamRadarCartRedirect

A patch for dream radar redirecting nds cart reading/writing to a file on the SD
GNU General Public License v3.0
74 stars 4 forks source link

Citra Support? #11

Closed wertercatt closed 1 year ago

wertercatt commented 1 year ago

Is there anyway you can get this working in Citra? I have my white2 savefile at \sdmc\roms\nds\saves\white2.sav in Citra's user directory, and radar\white2.ips renamed to code.ips in \load\mods\00040000000AE100. But when I go to 'Transfer Research Data' I get half a second of a white screen and then the emulator crashes.

wertercatt commented 1 year ago

citra_log.txt

Realized I should post the crash log

zaksabeast commented 1 year ago

Hey, sorry for the late response.

Please try this patch and let me know how it goes: patch.zip

I was able to transfer Pokemon using the attached patch in citra, and I loaded my white 2 save to confirm the transfer was successful:

Screen Shot
KostaSaizo7 commented 1 year ago

Hey, I am also interested in this. I managed to initiate and complete the transfer in Citra (Windows 10), but the \sdmc\roms\nds\saves\white2.sav file wasn't modified. I loaded it in melonDS and the Unova Link shows no data.

image

Also, the Pokemon I had in Dream Radar are gone now :(

image

zaksabeast commented 1 year ago

This version of the patch is a rewrite I made last August, so it isn't new and has been previously tested on consoles, including in this other issue. No changes were made between last August and the file I posted in the previous comment.

I tested on Citra again and was able to receive the Pokemon without issue, so I'm not able to reproduce this behavior. I made sure to confirm the white 2 save did not have any pending transfers before testing.

The patch has worked for multiple people on physical consoles, and I'm able to use it successfully on Citra. You are able to initiate a transfer on Citra, so the patch appears to be working for you too. The only issue appears to be finding the transferred Pokemon.

It's unlikely the patch works successfully for multiple people, and partially works for one person, but the second half fails for one person. Without more info, it's difficult to see how the Pokemon weren't transferred successfully.

Here are a few questions that might help debug:

KostaSaizo7 commented 1 year ago

citra_log.txt

I hope this log helps.

A little more detailed explanation: I went to AppData\Roaming\Citra\sdmc and created \roms\nds (since there wasn't one). I put a pokemon white 2 rom there and renamed it white2.nds. Also, I created a \saves folder and I put my pokemon white 2 save and renamed it white2.sav.

For your questions:

wertercatt commented 1 year ago

I had the same issue with the new patch, fortunately I backed up my Dream Radar save data first. Dream Radar acts like it sent properly, but White 2 says it didn't get it. Attaching my save files and citra log saves.zip citra_log.txt Original locations: \sdmc\roms\nds\saves\white2.sav \sdmc\Nintendo 3DS\00000000000000000000000000000000\00000000000000000000000000000000\title\00040000\000ae100\data\00000001\cygsavedata.dat

wertercatt commented 1 year ago

I tried moving the roms folder to nand as a troubleshooting step, and Dream Radar said the game wasn't inserted, so it is reading the SAV file. But it still wouldn't write to it.

wertercatt commented 1 year ago

Asked about the issue in the Citra discord, and they said to check if the version of Dream Radar is incorrect for the patch. I'm using the titleid listed in the repo, so is there potentially an update for Dream Radar that I'm missing?

KostaSaizo7 commented 1 year ago

I also tried it with a "clean" Citra portable in Windows Desktop, same error:

[ 31.117222] Service.FS core/file_sys/archive_sdmc.cpp:OpenFileBase:109: (unreachable) Unknown error opening C:\Users\Kostas\Desktop\head/user/sdmc/roms/nds/saves/white2.sav [ 31.117231] Service.FS core/hle/service/fs/fs_user.cpp:OpenFileDirectly:128: failed to get a handle for file [Char: /roms/nds/saves/white2.sav] mode=3 attributes=0

zaksabeast commented 1 year ago

It's good to know the issue is reproducible by both of you.

Both of you have the save file in the correct place. Dream Radar checks to see if a cartridge is inserted before attempting a transfer, and the patch replaces that check to see if the save file exists. If the file isn't in the right place, you should see a message saying a Black 2 or White 2 cart is not inserted.

Not sure how to check that

I haven't used Windows in a very long time, so I'm not quite sure what read-only rules exist for certain directories. Have either of you tried running citra as admin?

I'm using the titleid listed in the repo, so is there potentially an update for Dream Radar that I'm missing

To my knowledge, Dream Radar didn't receive an update. I checked my console, and it indeed only has the base version without an update.

@wertercatt Thank you for posting your save files. Curiously, I was able to transfer successfully from Dream Radar to White 2 using your saves files, and confirmed the Pokemon were in the White 2 save.

So we know the same patch, game, and saves work for me. That means there's something different between out setups outside of the patch, games, and saves.

A few more questions come to mind:

  1. What version of citra are both of you using?
  2. Have you tried running citra as admin?
  3. Just to make extra sure, are you waiting until this screen before closing citra? Screen Shot 2023-01-24 at 7 11 37 AM
KostaSaizo7 commented 1 year ago
  1. I tried with Citra Canary 2375, Nightly 1829 that read and write at C:\Users\ [user]\AppData\Roaming\Citra. Also, as I said above, I tried with a "clean" portable version "HEAD-dd6f23f" that read and write at a chosen directory. citra_log (4).txt

  2. Yes, didn't work

  3. Yes I also asked and uploaded a log in Citra discord, they haven't responded yet.

@zaksabeast I have also DMed you at Discord

zaksabeast commented 1 year ago

Thanks for the answers. Any write related issues shouldn't be the cause with a Desktop directory, so that doesn't seem to be it either.

I'm using a citra build from last October. Maybe try an older build from around that time and see if something changed between then and now?

I'm almost never on Discord, so it's not a great way to reach me sadly. GitHub is usually where I'm most responsive. Any questions or thoughts that could help solve the issue should be put in this thread since it might be useful info for others now and in the future.

wertercatt commented 1 year ago

Extracted the Discord conversation for reference. wertercatt is me (obviously) and SleepingSnake is a moderator in the server offering support. KostaSaizo7 is the same person in this thread.

[1:14 PM]wertercatt: I'm trying to use a code IPS patch that writes to a file on the SD Card. It's successfully reading the file from user/sdmc/ but it's not successfully writing. I don't see any information about why in the log file on the INFO log filter, is there a filter I could use to help the patch author troubleshoot?
[1:25 PM]SleepingSnake: Are you using the layeredFS modding system for this?
[2:15 PM]wertercatt: Just code.ips in the load folder
[2:17 PM]SleepingSnake: And this works correctly on the 3DS?
2:18 PM]wertercatt: Patch creator says it works on 3DS, and it works in Citra on their machine. But me and another user have had issues with it writing.
[2:18 PM]wertercatt: https://github.com/zaksabeast/DreamRadarCartRedirect/issues/11 Here's a link to the issue on the patch's github repo for more details
[2:19 PM]SleepingSnake: I see. In that case, double check whether this patch requires a certain game update version to be installed before usage. Some mods also only work on certain versions of the game. For example, some are region sensitive. 
[2:19 PM]SleepingSnake: Using any cheat codes might also not work correctly, as mods can change memory addresses.
[2:20 PM]SleepingSnake: Beyond this, make sure to also launch Citra as an administrator.
[2:20 PM]SleepingSnake: Since it's trying to write to a folder in appdata.
[12:48 AM]KostaSaizo7: Hi I am also trying the https://github.com/zaksabeast/DreamRadarCartRedirect patch. I tried running citra as an administrator, didn't work. It reads the file but can't write. I also tried with a "clean" portable Citra folder in windows desktop, still nothing. Here's a log.
https://cdn.discordapp.com/attachments/220742362740162560/1067335117984497754/citra_log.txt
10:49 AM]KostaSaizo7: Any thoughts on this?
11:01 AM]SleepingSnake:
[   3.420129] Service.FS <Critical> core/file_sys/savedata_archive.cpp:OpenFile:91: (unreachable) Unknown error opening C:\Users\Kostas\Desktop\head/user/sdmc/Nintendo 3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/00040000/000ae100/data/00000001/cygsavedata.dat
[   3.420148] Service.FS <Error> core/hle/service/fs/fs_user.cpp:OpenFile:77: failed to get a handle for file [Wchar: /cygsavedata.dat]
[   3.784543] Service.FS <Warning> core/hle/service/fs/file.cpp:OpenLinkFile:214: (STUBBED) File command OpenLinkFile Path: [Binary: 000000000000000000000000]
[   3.935084] Render.OpenGL <Warning> video_core/renderer_opengl/gl_driver.cpp:DebugHandler:68: API PERFORMANCE 131154: Pixel-path performance warning: Pixel transfer is synchronized with 3D rendering.
[   5.831430] Service <Error> core/hle/service/service.cpp:ReportUnimplementedFunction:163: unknown / unimplemented function 'ReplySleepQuery': port='APT:U' cmd_buf={[0]=0x3e0080, [1]=0x300, [2]=0x0}
[   5.832068] Service.SRV <Warning> core/hle/service/sm/srv.cpp:Subscribe:210: (STUBBED) called, notification_id=0x208
[   5.832280] Service.SRV <Warning> core/hle/service/sm/srv.cpp:Subscribe:210: (STUBBED) called, notification_id=0x20A
-
[   9.469522] Kernel.SVC <Error> ./core/hle/kernel/svc_wrapper.h:Call:294: level=27 summary=7 module=1 description=1015
[  13.808330] Service.FS <Critical> core/file_sys/archive_sdmc.cpp:OpenFileBase:109: (unreachable) Unknown error opening C:\Users\Kostas\Desktop\head/user/sdmc/roms/nds/saves/white2.sav
[  13.808342] Service.FS <Error> core/hle/service/fs/fs_user.cpp:OpenFileDirectly:128: failed to get a handle for file [Char: /roms/nds/saves/white2.sav] mode=3 attributes=0
[  13.808620] Kernel.SVC <Error> ./core/hle/kernel/svc_wrapper.h:Call:294: level=27 summary=7 module=1 description=1015
[  13.808721] Kernel.SVC <Error> ./core/hle/kernel/svc_wrapper.h:Call:294: level=27 summary=7 module=1 description=1015
[11:01 AM]SleepingSnake: Most likely this.
[11:01 AM]SleepingSnake: Not sure what's causing the path to be unreachable though. Especially since the author of the mod said it worked in Citra for him.
[11:02 AM]SleepingSnake: Since I can see that you have no game update installed, perhaps try to update that first?
[11:02 AM]KostaSaizo7: The author uses macos
[11:02 AM]KostaSaizo7: Me and the other user use windows
[11:02 AM]SleepingSnake: MacOS is generally more restrictive about stuff like this though.
[11:03 AM]KostaSaizo7: Update the game you mean?
[11:03 AM]SleepingSnake: Yes.
[11:03 AM] 
BOT Citra: Please refer to our game dumping guides. 
For Cartridges: https://citra-emu.org/wiki/dumping-game-cartridges/ 
For Installed Titles: https://citra-emu.org/wiki/dumping-installed-titles/ 
To dump DLC and Updates, use this guide https://citra-emu.org/wiki/dumping-updates-and-dlcs/ and install the results through File -> Install CIA...
[11:03 AM]SleepingSnake: Third link ^
KostaSaizo7 commented 1 year ago

Tried in Citra nightly-1790 from Oct 6, 2022, same behavior

wertercatt commented 1 year ago

In response to your questions though: 1) Latest Nightly, currently 1830. 2) I have ran it as administrator with no results. 3) I always wait until Dream Radar returns to the main menu before closing the game.

The only things I can think of that could be relevant: decrypted or encrypted CIA? I'm using a decrypted CCI personally. 3DS system archives/keys? Do you have the system archives setup for your copy of Citra, as I don't. And I assume KostaSaizo7 doesn't either.

wertercatt commented 1 year ago

My only other idea, although a far fetched one, is that maybe Citra's messing up somewhere in the / to \ conversion in filepaths? Which would explain why it's not working on Windows, but is working on your Mac. I'd need to boot into Linux to test that though.

wertercatt commented 1 year ago

My only other idea, although a far fetched one, is that maybe Citra's messing up somewhere in the / to \ conversion in filepaths? Which would explain why it's not working on Windows, but is working on your Mac. I'd need to boot into Linux to test that though.

https://github.com/citra-emu/citra/issues/6261 Did some digging into Citra's code, and this appears to indeed be a Citra bug. I'd still like to test my hypothesis by booting the game on Linux though, which would work around the incorrect file path handling.

zaksabeast commented 1 year ago

decrypted or encrypted CIA? I'm using a decrypted CCI personally. 3DS system archives/keys? Do you have the system archives setup for your copy of Citra, as I don't. And I assume KostaSaizo7 doesn't either.

Decrypted/encrypted cia and system archives shouldn't affect the game's ability to open a file on the sd card.

maybe Citra's messing up somewhere in the / to \ conversion in filepaths? Which would explain why it's not working on Windows, but is working on your Mac. I'd need to boot into Linux to test that though.

Windows vs. Mac really is the only difference I can think of too, but I've been a bit reluctant to mention it until we've exhausted all other possibilities. It feels like we're at that point though.

KostaSaizo7 commented 1 year ago

I installed Ubuntu on my laptop and did exactly the same steps and it worked!

So this definitely a bug that is Windows related. As @SachinVin said in https://github.com/citra-emu/citra/issues/6261#issuecomment-1407696732, it has to do with the file that "cannot be accessed because it is being used by another process"(likely citra itself).

image

zaksabeast commented 1 year ago

Thanks for testing - I'm glad to hear it's working for you on Linux.

I wasn't aware Windows locked files in the way that was described, which made me wonder if the patch wasn't closing the file properly. It closes the file here, here, and here, but I noticed two of those have a small bug that would cause the file to not be closed.

I adjusted the patch and used gdb to confirm the files were closed correctly. Please let me know if this solves the issue: patch.zip

wertercatt commented 1 year ago

image Confirming Windows functionality!

KostaSaizo7 commented 1 year ago

Thanks for fixing the Windows patch. I also did test the android Citra port and to my surprise it works perfectly! Now I can play Pokemon Dream Radar using my phone's camera and transfer the save to melonDS android port! Screenshot_2023-01-31-08-11-37-343_me magnum melonds

zaksabeast commented 1 year ago

Excellent! I'm glad to hear you two are able to use the patch. Thank you for testing things and helping look into this!

I've pushed the changes to the main branch and published a new release with this fix.