Homebrew TWPatcher - DS(i) mode screen filters and patches

  • Thread starter Sono
  • Start date
  • Views 751,440
  • Replies 2,428
  • Likes 101

Are you interested in a complete replacement of TwlBg which includes all patches?

  • Yes, I don't care how broken it will be!

    Votes: 188 79.3%
  • No, I don't want to use even more broken stuff

    Votes: 20 8.4%
  • Yes, but only in GBA mode, because I play DSi exclusives

    Votes: 12 5.1%
  • No, because I only use DS and DSi mode

    Votes: 17 7.2%

  • Total voters
    237
  • Poll closed .

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,328
Country
Hungary
Thanks. It worked. But yesterday night I applied too strong of a filter. I wish
1) it was quicker to switch from a config to the other (have multiple presets saved and ready?)
2) the patcher memorized the last settings and you didn't have to re-check everything

1) It's not really possible sadly, and it also annoys me. It takes a long time to compress the data. I could've saved a lot of time on compression if Nintendo didn't enforce it, but even then they made it the smallest size possible, so I can't take any shortcut, I can't inflate the size of the data, otherwise bad things will happen.
2) It was never intended that you'd use this more than once, so it's pointless to add configs. Why exactly do you need a config? I want to know about your usecase that requires a config to be added.
 

sneffel

Member
Newcomer
Joined
Aug 27, 2022
Messages
8
Trophies
0
Age
23
Location
Monza
XP
47
Country
Italy
1) It's not really possible sadly, and it also annoys me. It takes a long time to compress the data. I could've saved a lot of time on compression if Nintendo didn't enforce it, but even then they made it the smallest size possible, so I can't take any shortcut, I can't inflate the size of the data, otherwise bad things will happen.
Yes I get that, but could you store the two different generated files and keep them for later and then just switch them? Or do they have to be up-to-date and be compressed every time?
2) It was never intended that you'd use this more than once, so it's pointless to add configs. Why exactly do you need a config? I want to know about your usecase that requires a config to be added.
Imagine I wanted to try a different compression mode or I was just unsatisfied with a setting, I have to do the compression all over again. It would be nice to have at least the previous configuration saved or some presets
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,328
Country
Hungary
Yes I get that, but could you store the two different generated files and keep them for later and then just switch them? Or do they have to be up-to-date and be compressed every time?

Imagine I wanted to try a different compression mode or I was just unsatisfied with a setting, I have to do the compression all over again. It would be nice to have at least the previous configuration saved or some presets

Ah, I couldn't quite get what you wanted, but I get it now.

I have actually considered these to *some* degree, but there is a slight problem: I have absolutely no idea where and how to store this data. This has even been requested by some folks in the DS scene who want to manage variations of TwlBg.cxi just by inspecting the file itself, but I never really managed to find a solution.
This time it is actually possible to solve this problem, and I do have the knowledge and experience to be able to solve it, but I'm simply just lost for words, and can't evaulate if I actually want or need to do it.

You see, the original idea was short time after releasing the patcher is to actually just throw Nintendo's code out of the window, and just make my own.
This has happened to some degree, but it's nowhere near finished to be able to have a public release. It does work, but there is no touchscreen support, and there is also no image scaling, so it's clearly unfinished.
As for why I never ended up continuing this project is a story not meant for this thread, but let's just say that I have a difficulty working on homebrew anymore, possibly forever, so it'll never happen from me.

tl;dr: the reason there are no settings, is because TWPatch was meant to be a temporary workaround to a problem, and I was working on a *real* sustainable solution, but due to complications I have limited ability to be a developer anymore, so it will never be released, and so TWPatch remains in feature limbo.

As for compression mode, it can *not* be changed. It is hardcoded in the legacy kernel, and unhardcoding it is so much work that it's basically impossible. It's easier to just re-make the entire damn thing from scratch.
There are still some ways to optimize the compressor slightly, but it's too late now for me to do it.

I'm sorry, but you'll have to use some tool made by the community to manage versions of TwlBg.cxi, or use the unofficial Luma fork, which should have it.

Oh right I might have mixed that up 😅 But if you need a new avatar I can always make you one!

Ah, that's fine. We can discuss this in a profile post, I think.
 

cjuni

Active Member
Newcomer
Joined
Jun 7, 2022
Messages
32
Trophies
0
Age
27
Location
Earth
XP
155
Country
Brazil
@Sono is there a way to make it so that unsupported games go automatically into the 4:3 instead of 16:9 stretched?
I know that i can change in twilight menu but i'm using nds forwarder for launch games directly from home menu.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,328
Country
Hungary
I would like to know if TWPatcher also apply the screen filtering to DS retail cartridges?

TWPatch patches the DS mode support software, so it works with anything which runs in DS mode. So cartridges and installed digital titles also work.

Is there a way to make it so that unsupported games go automatically into the 4:3 instead of 16:9 stretched?
I know that i can change in twilight menu but i'm using nds forwarder for launch games directly from home menu.

It was possible at one point, but I have never finished it due to hassle with patching, and also the instability between DS and 3DS mode. Not to mention, changing the stretching in real time messes with upscaling, which causes more issues on its own, so I have scrapped the idea completely in TWPatch.

Widescreen toggle however was thought to go into LgyBg, but I'm no longer able to code properly, so it will probably be never implemented by me.

Sorry.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,328
Country
Hungary
Well, that is obvious 😅. What patch do you recommend for the N3DS XL?

The same for every 3DS.

For 3D games, it might be better to use GPU scaling*, and for 2D games "Sono's crisp" might work better. I would say "you can read back this thread to see others' opinions", but I do not wish anyone to read through 111 pages just to find that you don't like someone else's opinion.
You can see how it would look approximately by switching between the filters, and also switching between the test images by X+DPAD, and switching rapidly by Nintendo's default and the selected filter by pressing and releasing X.

* if you get sick from blurred images like I do, then you might want to use one of the broken "linear interpolation" filters. You know it's broken, when you look at the top-left corner of the bottom screen, the settings wrench will have extremely jagged edges compared to the other filters.
 
  • Like
Reactions: malekmaroc7

RetroGen

Well-Known Member
Member
Joined
Jul 17, 2022
Messages
181
Trophies
0
Location
Home
XP
698
Country
Canada
TWPatch patches the DS mode support software, so it works with anything which runs in DS mode. So cartridges and installed digital titles also work.
Excuse my ignorance, but please explain how TWPatch works with installed and cartridge DS(i) games. Generally, I've been using TWLMenu++ for running DS games with TWPatch enabled using Linear sharpen 1 and it makes a noticeable improvement to image quality. I was under the impression that the default Nintendo upscaler is applied unless launching DS titles with another program. Is there a way to make TWPatch permanent or does it have to be launched first or ??? Thanks!
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,328
Country
Hungary
Excuse my ignorance, but please explain how TWPatch works with installed and cartridge DS(i) games. Generally, I've been using TWLMenu++ for running DS games with TWPatch enabled using Linear sharpen 1 and it makes a noticeable improvement to image quality. I was under the impression that the default Nintendo upscaler is applied unless launching DS titles with another program. Is there a way to make TWPatch permanent or does it have to be launched first or ??? Thanks!

Think of it like this:

There is a DSi inside of the 3DS.
There are multiple "switches" inside of the CPU which change a few things over from the 3DS to the DSi CPU, like the buttons, the RAM, the NAND, and a few other things. There are some things which can be still controlled from the 3DS side after a switch (like touchscreen and the buttons), but the rest (like FCRAM and NAND) are no longer accessible to the 3DS CPU in DSi mode.
The 3DS LCDs are incompatible with the DSi's LCDs, so Nintendo made it so that the output from the DSi display controllers go into an embedded capture card.
Because of this, it's possible to modify the image before it's copied to the 3DS LCD.

The above is handled by some code running in 3DS mode, and TWPatch patches this code, and places the patched result to your SDCard, which is then loaded by Luma, instead of loading it from NAND, where it's normally installed to.
tl;dr:
- In DSi mode, some hardware is switched over from the 3DS side to the DSi side, like FCRAM, the face buttons, the NAND, and other things.
- The DSi CPU's LCD output is hooked up to an internal capture card, which makes it possible to have the image modified before it's copied to the LCD manually.
- This is handled by some code installed to NAND, but TWPatch patches this code, and copies it to a specific location on the SDCard for Luma to load it.

So basically if Luma is configured correctly, then patching the code in TWPatch should have an instant effect next time you launch into DSi mode. If the CPU switches into DSi mode using Nintendo's code, then the code patched by TWPatch will be loaded by Luma, and that's how these patches and filters get patched in.

I hope this is understandable and, not too technical. Feel free to ask, I'll try to reword it if it's not clear, or too long.
 
  • Like
Reactions: RetroGen

RetroGen

Well-Known Member
Member
Joined
Jul 17, 2022
Messages
181
Trophies
0
Location
Home
XP
698
Country
Canada
So basically if Luma is configured correctly, then patching the code in TWPatch should have an instant effect next time you launch into DSi mode. If the CPU switches into DSi mode using Nintendo's code, then the code patched by TWPatch will be loaded by Luma, and that's how these patches and filters get patched in.

I hope this is understandable and, not too technical. Feel free to ask, I'll try to reword it if it's not clear, or too long.
Thanks for the explanation.

Is there anything that needs to be done with the configuration of Luma? Enable loading of external FIRMS and modules is enabled. I'm using the unofficial Luma 11 build with Night/Light from here, and use Redshift for adjusting the white balance on both screens. If I understand correctly, once TWPatch has been run, Luma should apply the Linear sharpen 1 upscaling algorithm automatically when launching DS(i) games from the home menu.

BTW, my great grandparents emigrated from Hungary over a century ago.

EDIT: Installed my DS games to the home menu with ndsForwarder and upscaling seems to work as stated above. It's nice to be able to run them directly from the 3DS home menu with TWPatch upscaling rather than using TWLMenu++. Thanks! TWPatch works for installed DSi games as well, correct?

Linear sharpen 1 seems to do a great job by adding a slight-but-appreciated amount of sharpening without any serious image degradation, improving legibility of text and providing a clearer overall picture. The other sharpening algorithms all seem to lose image fidelity by going too far IMO, giving a more "crunchy" pixelated look. IMO, there isn't enough native resolution in DS games to support upscaling to a decent quality widescreen image; it's possible, but looks rough and pixelated and I prefer to stick with cleaner looking 4:3.
 
Last edited by RetroGen,

malekmaroc7

モロッコの人だよ
Member
Joined
Mar 18, 2017
Messages
243
Trophies
0
Age
22
XP
1,246
Country
Morocco
TWPatcher seems to have applied the patches but whenever I insert a DS cart, it still shows me the unpatched DS mode.

EDIT: Fixed it by enabling patches from Luma3DS configuration screen.
 
Last edited by malekmaroc7,

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,328
Country
Hungary
Thanks for the explanation.

Is there anything that needs to be done with the configuration of Luma? Enable loading of external FIRMS and modules is enabled. I'm using the unofficial Luma 11 build with Night/Light from here, and use Redshift for adjusting the white balance on both screens. If I understand correctly, once TWPatch has been run, Luma should apply the Linear sharpen 1 upscaling algorithm automatically when launching DS(i) games from the home menu.

You only need to enable game patching and module loading (I think it got merged into a single option in newer versions).

TWPatch patches TWL_FIRM found on the NAND, but instead of writing it back to NAND, it writes it to SD (/luma/sysmodules/TwlBg.cxi and/or /luma/twl.firm), and when the system tries to boot TWL_FIRM, Luma intercepts that, and instead boots from SD instead.

TWPatch works for installed DSi games as well, correct?

Because of the above reason, yes.

Linear sharpen 1 seems to do a great job by adding a slight-but-appreciated amount of sharpening without any serious image degradation, improving legibility of text and providing a clearer overall picture. The other sharpening algorithms all seem to lose image fidelity by going too far IMO, giving a more "crunchy" pixelated look. IMO, there isn't enough native resolution in DS games to support upscaling to a decent quality widescreen image; it's possible, but looks rough and pixelated and I prefer to stick with cleaner looking 4:3.

The problem is that I'm making these filters BY HAND, so it's not easy to add any more extra effects onto it.
Although I think Linear sharpen 1 is literally Nintendo's scale filter with MORE sharpening. You can confirm this yourself if it's true by selecting Linear sharpen 1 in the menu, wait for the menu to disappear, and start holding and releasing X to see the difference.

Edit: I can't read, lol
 

RetroGen

Well-Known Member
Member
Joined
Jul 17, 2022
Messages
181
Trophies
0
Location
Home
XP
698
Country
Canada
Thanks, Sono. After posting that I read through the entire thread and now have a better understanding of how TWPatch works. Those newb questions were answered earlier in the thread.

Also had a chance to try mGBA in 800x240 mode and was very impressed by the quality of the upscaling in Binlinear (pixelated) mode. I compared it with your AGB_FIRM and open_agb_firm, and the difference in image quality was obvious. So, I'm now sold on 800px mode for the best possible upscaling quality. The higher resolution might offer a subtle improvement to some, but to my eyes it strikes perhaps the ideal balance between smoothness and detail preservation. Haven't seen anything better than Linear sharpen 1 for DS games yet, however... and it is great that it works with VC titles.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,823
Trophies
2
Location
home
XP
9,328
Country
Hungary
may i ask what do you mean by this? doesn't quite sound like "i don't have time for this" but perhaps a health issue? Hope you're okay

Yeah, health issue. Though the details are probably not much relevant to this thread (I can answer outside this thread).

tl;dr: can't get access to necessary meds, though even with those I'm still barely able to code.
 

zarke661

Active Member
Newcomer
Joined
Sep 10, 2021
Messages
29
Trophies
0
Age
28
XP
559
Country
Brazil
Because of the above reason, yes.



The problem is that I'm making these filters BY HAND, so it's not easy to add any more extra effects onto it.
Although I think Linear sharpen 1 is literally Nintendo's scale filter with MORE sharpening. You can confirm this yourself if it's true by selecting Linear sharpen 1 in the menu, wait for the menu to disappear, and start holding and releasing X to see the difference.

Edit: I can't read, lol
are you improving the filters?
 
Last edited by zarke661,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: For your steam deck ken?