-
Notifications
You must be signed in to change notification settings - Fork 11
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
Cancellation support #5
Comments
Yes. I think this would be worth adding. |
Have you made any other changes to this? The reason I'm asking is that one of the things I think would be useful is if I separate the DiscUtils fork into a separate project (still part of this repo) and retarget to .NET Standard 2.0. That way it can be consumed by other projects as a .dll from any version of .NET 4.8 and above. I'm going to retarget the UI and console builds to .NET 8, but I think there's value in targeting .NET Standard with a shared DLL because .NET 4.8 still ships preinstalled with Windows 10 & 11 and I'm sure some people still target that on purpose so their users don't need to install anything. I think the last .NET Core builds I posted were probably self contained, but some people might dislike the large binaries that result from that. I'm not sure if anyone would benefit by consuming this as a DLL or if I should just leave the code as-is and people can just continue having complete copies of it. I believe FamilyGuy was just using the command line version, but I haven't looked at his stuff in years. |
Hi, thanks for the response! I absolutely would use this as a separate library. It was one of the things I thought of when I first used GDI Builder in my project. I haven't made any other changes besides the cancellation thing, but I do have some ideas to explore, and I'll be happy if you consider any of these if they fit the purpose and scale of the project.
I was going to look into addressing 2 and 3 myself by looking at the decompilation of japanese-cake's GDROM Explorer and rewriting some of the Python tools in C#, but if anything like this is implemented in GDI Builder I would love to use it! |
Completely understandable. Looking forward to the update! |
This is what I get for not looking at the code before I reply. 😕 DiscUtils is already its own separate .NET Standard 2.0 library. Other changes still pending. |
I've pushed a new branch called Cancellation which generally follows a similar approach to what you did. Some differences:
I may release this update as-is, or I might do more with it. I'm not sure yet. When implementing cancellation tokens I thought "why not make an async version of BuildGDROM()?" since most apps with background activity use async instead nowadays. But that would have to go all the way down into DiscUtils. There's a fork of DiskUtils that implements async and other modern .NET features, but I'd have to reimplement the GD-ROM specific changes to use that. It's probably not worth the effort for such a tiny performance boost right now. I still need to check on the reading stuff. Please let me know if you have any feedback on the changes so far in case there's something else I should change before finishing this up. |
I think the way you did it is better, I didn't really think it through in my fork because I needed a quick solution. |
Just a quick update on why nothing has been posted yet. Apparently I forked DiskUtils before it had ISO reading support, so I migrated my changes to a version from August 2021. There's an even newer fork with some additional optimizations, but that fork contained some modern .NET features that aren't available in .NET Standard 2.0 and I kind of wanted to leave the option for .NET 4.8 compatibility in there even though I'm targeting .NET 8 now. I would have considered forcing consumers of the library to update if it had await, but it actually didn't have that for ISO building even though it introduced it to other parts of the library. Out of the box it won't read GDI tracks because they're raw mode instead of pure ISO. I wrote an adapter class that basically reads raw as if it were ISO, which allows the PC Track01 to read fine but I still need to do additional work for the high density tracks to be readable. I didn't start digging into the details of the reader code yet, but it's not finding any files on the disc and I assume that's because it's expecting to be at the beginning of a disc instead of somewhere in the middle. I have no estimate on that, but I would be disappointed if I haven't looked into it further in the next couple weeks. |
@PiKeyAr If you check out my new commits to the Cancellation branch, I did a few things:
Example:
I assume your end goal is to be able to write a new disc without having to extract the original disc first. If that's the case I still have some more work to do, namely adding additional methods to GDromBuilder to let you add files from a stream instead of from a folder. That is probably all I have left to do before a new release, unless something else needs to be fixed. |
Hi! Sorry, I was away for two weeks, and now I need to catch up with work stuff, so I can barely do anything right now. I managed to extract files from the high density track of SA1 GDI using the new branch, haven't tested multi-track games yet. I ran into a problem with cancellation during the extraction phase in my program: the program hangs after the Task is cancelled, but it's not related to GDIBuilder since it hangs without it too. It's just my lack of understanding how async and Tasks work, so it'll take some time for me to resolve. When I figure it out, I'll be able to do more testing. Writing a new GDI without having to extract original files first sounds like a great option, so I'm happy if it gets implemented. At the moment though, my tool is built around having to extract all files first, and it has an option to let the user make final changes to the files manually before building the GDI. |
My commit yesterday has most of the changes needed to build a new GD without extracting files first. I still have a bit more work and testing to go; I hope to finish it up in the next week. I changed the entire build process so you now add the files yourself and the source for a file can both be an actual path or a stream. Plus, the order that you call AddFile() determines the order of files on the disc in case someone wants to control that. The biggest thing missing from reading is a ReadIpBin() method because the current commit has no way to access that but I have that method locally already. My next commit of buildgdi (the command line tool) should have a -rebuild argument which I'm using to try out "patching" an image. -rebuild in combination with -data should let a user provide a folder with only changed files and just copy the rest from the original disc. I'm also going to add an -extract argument because I might as well. Not sure yet how much of this I'll add to the GUI versions. If I had a lot of time I'd probably want to build a GD-ROM navigator to browse / extract, but for now I'll just add to the command line tool. |
I committed some more breaking changes to the Cancellation branch today, things that I wanted to improve while adding the -extract and -rebuild arguments to the buildgdi command line app. Both features appear to be working on my end, I can extract discs and IP.BIN and also rebuild them successfully while patching some files. The rebuild process used under 30MB of memory for an entire 1GB image and was nice and fast. I think the API changes are solid now, I have no more breaking changes to the methods & arguments available unless I get feedback that results in them needing to change. I'd like to publish DiskUtilsGD to Nuget once this is done so that developers can use this without having to pull down the code or a DLL. Program.cs in the buildgdi folder can function as an example of how to use the new API. I released a beta build of buildgdi here: I'd like to add these features to the GUI version too, but I think most people are using the command line version with a bunch of scripts right now. Releasing this beta should give me some time to rework the GUI's. |
This has been released |
Hi! Thank you for making this tool. I use it in this project that allows the user to add hacks to Dreamcast games.
I was wondering if you were interested in adding built-in support for cancelling an ongoing GDI build process via a separate method or a CancellationToken. I put together a crude hack that simply makes all data-heavy functions check the CancellationToken before reporting progress and return if cancellation is requested.
This is just a quick hack I did for my own purposes, so it would be nicer to have it implemented properly in the original version. What do you think?
The text was updated successfully, but these errors were encountered: