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

[FEATURE REQUEST] Add the ability to install carts and 3ds format game dumps to the SD card without converting to .cia first. #580

Closed
nl255 opened this issue Jan 11, 2020 · 17 comments

Comments

@nl255
Copy link

nl255 commented Jan 11, 2020

Describe the feature you'd like
It would be nice to be able to install physical cart based games or 3ds format game dumps to the SD card without having to convert it to a .cia first. Cartinstall can do this with physical carts but not 3ds files.

Describe alternatives you've considered
While it is possible to install cart based games or 3ds format dumps by converting them to a .cia file it is at least twice as slow and requires twice the free space on your SD card. The cartinstall fork of gm9 can do this with physical carts but not .3ds files but presumably the same method could be made to work with them as well.

@Wolfvak
Copy link
Collaborator

Wolfvak commented Jan 12, 2020

Before even adding such a feature we'd have to implement all the CartInstall features into the master GM9 source.

Still, once that's done I don't see any purpose to such a feature other than piracy - if you have the .3ds file it's logical to assume you also have the original cart (if you have the .cia, you should've dumped it from one of your consoles, too).

Will leave this open, but keep all of the above in mind.

@urherenow
Copy link

Oh, come on! .3ds, sure, but from the cart? Directly installing from cart, for one, requires you to have a cart. Benefits? You don’t need more than DOUBLE the size of the cart free on your card, for one. Second, it lets you keep all of your games with you, without having to carry a bunch of carts.

@nl255
Copy link
Author

nl255 commented Jan 12, 2020

You could say the same thing about most of the .3ds file related features in godmode9 including the feature to convert a 3ds to a cia. That goes double for the feature to correct badly decrypted .3ds files (as opposed to just warning or offering to rename them) since the only way to obtain those is via a "shady source".

@d0k3
Copy link
Owner

d0k3 commented Jan 12, 2020

I actually like the idea, but we're missing code to be able to do this. @aspargas2 is working on DISA support (needed for writing title.db and ticket.db), but I'm unsure about how far he got already. I'd suggest we leave this open for now, although there may be little to no progress for some time.

@Wolfvak
Copy link
Collaborator

Wolfvak commented Jan 12, 2020

The feature to correct the badly dumped ones was only added because way too many people were creating issues about it.

About the conversion routines, you could also argue that the CIA format (as created by GM9) is a lot more malleable and lends itself well to being modified. Really old game mods were distributed either as illegal CIA files or as less-shady Delta patches for the original CIA file.

The only reason the 3DS format was ever prevalent is Gateway and maybe Sky3DS, and neither are big concerns nowadays.

@aspargas2
Copy link
Collaborator

DISA/DIFF support is already in gm9 fully and is fully accessible in that you're able to writeably mount any DISA or DIFF file, including all the .db files, which are DIFF files. What's not accessible is the code for manipulating the BDRI filesystem inside the DIFF container for .db files; that code works already but is inaccessible to the user, so all I need to do is replace the old vtickdb code with stuff to use my BDRI code to mount any db file.

@d0k3
Copy link
Owner

d0k3 commented Jan 13, 2020

So, what's still missing to be able to install direct to SysNAND, @aspargas2? If it isn't too much, and if you're interested, of course, I wouldn't be too unhappy if you took this change into your hands. You may also point me in the right direction and I'll look into it (when I get to it).

@aspargas2
Copy link
Collaborator

The main thing that's missing is replacing the old vtickdb code with code to writeably mount a BDRI filesystem. I have partial progress on that and I know the backend of it works. Once that's done, which I really meant for it to be a long time ago, all that's left for an "Install" option on .3ds and .cia files is code to generate a .cmd, .tmd, and title info entry as needed and code to actually copy the contents, all of which is pretty easy. I was hoping you could do those last parts once we get to that stage, because I think it would be significantly less sloppy than if I did it

@d0k3
Copy link
Owner

d0k3 commented Jan 14, 2020

Yup, I can do that, no problem :).

@fox8091
Copy link

fox8091 commented Jul 4, 2020

Now that BDRI mounting is merged, is there anything else blocking this?

@d0k3
Copy link
Owner

d0k3 commented Jul 4, 2020

From what I know, I'd say that's titledb handling. Other than that it's just an affair of copying the right files to the right place. I'd like to read @aspargas2's take on that, tho.

@aspargas2
Copy link
Collaborator

Yeah, all that's missing now is code to generate a .cmd file and title info entry, and trivial code to add an "install" option on .3ds files (and presumably .cia flies as well) that would chain this whole process together. I probably shouldn't call that code trivial though, because it would be a good idea to sanity checks in it for things like if the ticket in a .cia is unique to another system.

@d0k3
Copy link
Owner

d0k3 commented Jul 7, 2020

Quoting @aspargas2 here with some useful tidbits of info:

I'm going to enable .3ds and .cia installing. Dunno how hard that will be.
couple tips/comments on that:

  • 3dbrew will probably have sufficient information for this, but if you're looking for example code for generating title info entry or anything else, you could look at cartinstall but it's somwhat crapcode in that part. https://git.ianburgwin.net/ianburgwin/rebuild-title-database (builds title info entries for sd titles) and https://github.com/ihaveamac/custom-install (does the entire installation process for a cia) are both python but may be more helpful than my impl.
  • it takes a couple seconds to mount ticket.db becuase it has to read every ticket to sort them into the virtual directories, so if the user selects a bunch of cias and installs them all, it would be cool if it only mounted the dbs once to install all tickets / title info entries. i've been thinking about improving it to have it mount ticket.db instantly then only do the sorting work if the user actually opens a directory, but it'll take me a while to get around to that.
  • the title.db on the sd card will often just not exist because no titles are installed yet, and for right now we'll just need to throw a friendly error in that case unless you want to bundle an empty sd title.db and import.db with gm9 (you don't). just opening the eshop or installing a small title with fbi will generate them.
  • the struct for a title info entry is currenly in bdri.h, but there's probably a better place for it.
    (hit enter early, had a couple more things)
  • though you need to mount the .db file as an image beforehand either way, it'll probably be easier to use the functions defined in bdri.h directly to work with installing/reading tickets and title info entries, rather than trying to use fs functions with the T: drive.

Yeah, you need to write a title info entry to the appropriate title.db (there's a seperate one for nand and sd) to have anything know the title is actually installed. You don't need to do anything with import.db. when hos installs titles, it writes the title info entry to import.db at the beginning of the install, then moves it to title.db, which is how it keeps track of partially complete installs and nand titles that have been downloaded but not installed, neither of which are things we need to do. What i do in cartinstall is just wait till the end of copying the contents to generate and install the title info entry and ticket, though it may be better to those things before copying the contents then undo them if the install fails or is cancelled. That way, if the ticket/title info entry installation fails for some reason, the user wouldn't have to wait a long time for the contenfa to copy juat to find out the install was going to fail anyway. Though, if title.db and ticket.db both exist, there shouldn't be any reason that installing things to them should fail unless they're fully corrupted somehow
Twl things just use the title.db/import.db in crtnand
Notably, the calculations for the "title size" field in the title info entry are different for nand titles, just a sec on that

@aspargas2
Copy link
Collaborator

Following up on the title size thing, it seems that the title size calculations are all different for SD titles, ctrnand titles, and twlnand titles, and I'm not sure if we know what they are for twlnand ones yet. Tagging @ihaveamac, as he probably knows more about this.

As far as SD titles go, the repositories I linked above should have good reference code. For ctrnand titles, the magic value 0x8000 (TITLE_ALIGN_SIZE in the code I linked) just needs to be replaced with 0x4000.

It should be noted that the title size field is merely cosmetic. It determines the number of blocks the title displays as taking in data management and its size in FBI, but has no effect on anything else.

@d0k3
Copy link
Owner

d0k3 commented Jul 31, 2020

Okay, @nl255, @urherenow and everyone who was waiting for this - here is something to try:

https://f.secretalgorithm.com/9lz1v/godmode9-v1.9.1-74-gda10a1b1-20200731114630.zip

It will do even more than what you asked for, and will allow to install CIA, NCSD (.3DS), NCCH, DSiWare .NDS and files downloaded from NUS/CDN (start with the TMD file here). Keep in mind this is still being worked on. Nothing really bad should happen, but having a backup, just in case, is always a wise decision.

@d0k3
Copy link
Owner

d0k3 commented Oct 13, 2020

I think we can close this now, this is in the current prerelease. We still got some work ahead of us, but most stuff works as it should.

@d0k3 d0k3 closed this as completed Oct 13, 2020
@urherenow
Copy link

urherenow commented Oct 14, 2020

Sorry to comment after the close, but I'm on deployment and don't get a lot of time on the 'net. I have (within just a few weeks) built a later source, and I have installed a game from a cart and from a .cia on an N3DS, and a newer 2DS model as well. Works great!

Don't know if this is valuable info or not, but if there is something wrong with the sd card (format, partition, FAKE, whatever), then selecting a .3ds or .cia file does not bring up that menu. It behaves as if it was some random file that you're selecting. The person with the 2DS that I had just hacked with an NTR card wanted to use a larger sd card. The 512GB card he had, was a name I've never heard of, and behaved like it was fake. I got things sorted on a Samsung EVO 256GB card though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants