TWPatch lets you use custom DS(i) mode scaling filters on your 3DS

twl_bricc_banner.png

Backward compatibility is always appreciated, there's no doubt about it. However, sometimes a console's implementation can be lacklustre, either due to technical difficulties or laziness on the manufacturer's part. Depending on who you ask, the 3DS' DS/DSi mode can be said to fit in either: your only options are to either play games upscaled to the 3DS' screen resolution, which includes a blurry filter that cannot be turned off, or in native res mode, which is hardly ideal as it doesn't make use of the entire screens - thus introducing big black bars all around. Due to it, some people preferred playing DS(i) titles on past consoles as it made a number of games look significantly better without any compromises.

But things are finally starting to change with the release of TWPatch made by @Sono. After lots of research and reverse engineering, he made a patcher that is able to change how TWL_FIRM's image upscaling behaves. A total of nine different scaling filters are available (not counting Nintendo's default one), several of which are able to make your games look much sharper than before! In order to give you an idea of what to expect, here is a comparison taken from the thread (made by @youny43 - left: default / right: patched) :

platsmooth.jpg platsharp.jpg

For the curious, here's a list of the included filters:
Filter list said:
  • Nintendo default
  • Sono's crisp (original patch)
  • Sono's crisp (tweaked)
  • Zero interpolation (double pixel)
  • Linear interpolation 1
  • Linear interpolation 2
  • Sharpen test 1
  • Linear sharpen 1
  • Darken crisp
  • Darken Nintendo

The patcher works on both Old and New 3DS models as long as they are running Luma CFW. You need to have enabled loading external FIRMs and modules in Luma's configuration menu, otherwise, the custom filters won't be applied. The process can take several minutes, so be sure to have enough battery charge (and patience) before proceeding. If you're unsure on which one to apply, you can preview how they'll look inside the homebrew app and compare it to Nintendo's default one.

If you want to try this yourself, make sure to read the instructions & remarks in @Sono's post before downloading (linked below).

:arrow:
Source
 

agarpac

Member
Newcomer
Joined
Jun 27, 2019
Messages
14
Trophies
0
Age
25
XP
115
Country
Indonesia
  • Like
Reactions: emcintosh

Sono

cripple piss
Developer
Joined
Oct 16, 2015
Messages
2,822
Trophies
2
Location
home
XP
9,327
Country
Hungary
sorry for very late reply. just got it tested
View attachment 407408
tested in some games and yea damn i oddly dig this eventhough is not good lmao
curse you, 3ds resolution!!
but yea this is good option for someone weird like me i suppose lol

Can you put it in words why it looks bad? I *know* that it is absolutely horrible in this state, but I'm not sure how I should adjust it.
 

agarpac

Member
Newcomer
Joined
Jun 27, 2019
Messages
14
Trophies
0
Age
25
XP
115
Country
Indonesia
Can you put it in words why it looks bad? I *know* that it is absolutely horrible in this state, but I'm not sure how I should adjust it.
i can't put my finger on it, but those squares are too visible even with more transparent.
this is lcd filter from melonds (android)
lcd filter supposed to have square border per pixel (or more), right?
as someone pointed out if i remember correctly.
it's barely visible because the out resolution is very big compared to internal reso.
1701770044222.png

i guess it's more to "how to hide not-so-good scaling with some darkened square lines" and the filter atm doesn't really hide the fact that the scaling is not good, probably because it doesn't have additional filter before that square filter.
sorry if i can't explain it right.
 
  • Like
Reactions: Sono

usersorei

New Member
Newbie
Joined
Dec 30, 2020
Messages
1
Trophies
0
Age
22
XP
53
Country
United States
Does anyone know the difference between Sono's crisp (original patch) and the tweaked version of it? Been wondering about it for a while now.
 

Vorty11

Member
Newcomer
Joined
Aug 6, 2014
Messages
12
Trophies
0
Age
42
XP
68
Country
United States
Does anyone know the difference between Sono's crisp (original patch) and the tweaked version of it? Been wondering about it for a while now.
same question! Also, how do we enable these filters on the fly? I don't quite understand the process for enabling/disabling them at will.
 

Sono

cripple piss
Developer
Joined
Oct 16, 2015
Messages
2,822
Trophies
2
Location
home
XP
9,327
Country
Hungary
Sorry that I missed some replies, this is not the main thread!

Does anyone know the difference between Sono's crisp (original patch) and the tweaked version of it? Been wondering about it for a while now.

Don't use the tweaked one then, as it looks worse in 2D. Stick with the original one, unless you play with a 3D game where the tweaked one looks better.

Also, how do we enable these filters on the fly? I don't quite understand the process for enabling/disabling them at will.

You don't. This is a technical limitation with Nintendo's code, and there is nothing I can do about it :/
You must re-patch every time, which means ~6minutes every try.

Basically, there is not enough space in the remaining RAM (that is not mapped over to the DSi side) to keep more than a single scale matrix. Also, Redshift is applied *before* switching, as the extra RAM is needed to decode and store the Redshift curves.
And no, sadly I can't squeeze it down more, it's already as low as I could get it. I'm counting *bytes* of free space already for other patches. This is the best I can do within the confines of Nintendo's code.

A rewrite is in the works, which solves all of these issues. No ETA.


Although... with rtcom it is technically possible to switch the scale matrixes *and* redshift at runtime.
But patches like widescreen are extremely destructive, and can not be undone and/or re-done without a patch again in TWPatch.

Again, this is solve-able in user code, this is not a hardware limitation. This is Nintendo's bad code limitation.
 

Vorty11

Member
Newcomer
Joined
Aug 6, 2014
Messages
12
Trophies
0
Age
42
XP
68
Country
United States
You don't. This is a technical limitation with Nintendo's code, and there is nothing I can do about it :/
You must re-patch every time, which means ~6minutes every try.
Thanks for clarifying. But to be clear, if I want to switch filters, I just have to go through the process of saving the TwlBg.cxi again using your patch? Then the new filter selected should apply automatically? If so, then I really appreciate the preview function you put into the patch.

Two more quick (hopefully) questions:
  1. Are you able to describe in more detail what each of the filters does? The names aren't totally obvious.
  2. When enabling the widescreen patch, there's also the option of "enable GPU scaling (blurry, no filters)" What does that actually do, and should it be combined with your filters? Or does enabling this option just make the widescreen as blurry as the original 4:3 option?
 

Sono

cripple piss
Developer
Joined
Oct 16, 2015
Messages
2,822
Trophies
2
Location
home
XP
9,327
Country
Hungary
Thanks for clarifying. But to be clear, if I want to switch filters, I just have to go through the process of saving the TwlBg.cxi again using your patch? Then the new filter selected should apply automatically? If so, then I really appreciate the preview function you put into the patch.

Two more quick (hopefully) questions:
  1. Are you able to describe in more detail what each of the filters does? The names aren't totally obvious.
  2. When enabling the widescreen patch, there's also the option of "enable GPU scaling (blurry, no filters)" What does that actually do, and should it be combined with your filters? Or does enabling this option just make the widescreen as blurry as the original 4:3 option?

Yeah, you sadly need to re-patch it every time. The highlighted filter is used. Perhaps I should change how it works, as the filter selection was made when the patch menu did not exist, so it's just confusing now the way it is, that you must press A to enable the patches, but you must highlight the filter you want to use before pressing START, definitely confusing...

In hindsight, I should've added the preview function much earlier than I did... But at least it's in. Although I should probably finally fix the GBA previews at some point...

I've already optimized the code once, and it went down from 6m23s to 5m53s on old3DS, but the wait is still painful... It's probably still possible to make it go faster, but I'm reaching the limits of the CPU itself, so even if I had single-cycle memory, it would be still slow.

I'll try my best to remember the origin of each scale matrix, but here are the stories I can remember:
  • Nintendo default - copypasted directly from TwlBg, it *is* the default
  • Sono's crisp (original) - it's basically the least amount of interpolation possible. Basically the GBA upscale filter modified for DS(i). This one looks better with 2D games, but also okay with 3D.
  • Sono's crisp (tweaked) - you're right that you don't see the difference, as the difference is in the subpixel! This one looks better in 3D, as there is some slight antialiasing effect in this one, but it looks horrible in 2D due to weird colorbleed.
  • Zero interpolation (double pixel) - it's Sono's crisp, but without any blurring. Just as its name says, the interpolated pixel is doubled instead of blurred.
  • Linear interpolation 1 - it is as pure linear interpolation as I can get (first output pixel is in the center of the first input pixel, meaning the first pixel is unchanged). If you hold X, you can see that Nintendo's default filter is actually sharper than pure linear, due to edge-detect. However Nintendo did something weird with that edge-detect, as it causes some artifacts around some edges, which looks bad in some cases.
  • Linear interpolation 2 - different kind of linear interpolation. I think this one might be broken, as the order of the matrix may be reversed, so it creates a really weird jagged effect.
  • Linear interpolation 3 - this one might also be broken due to a reversed matrix. This one has the pixel center point shifted by half a pixel, so there are no output pixels which perfectly fall into the center of an input pixel, meaning the output will always be blurry on purpose.
  • Linear interpolation 4 - this is Linear interpolation 3, but shifted half a pixel, so one of the output pixels is on the center of an input pixel, meaning not everything is a blurfest. Similarly to the rest, this one may be reversed too, creating a weird jagged edges on perfectly diagonal lines.
  • Sharpen test 1 - this is one of the broken filters (which has been removed since), but with an extremely aggressive edge-detect applied to it. Again, due to accidentally being reversed, diagonal edges are really jagged instead of perfect diagonal. This one is primarily for 2D games with text.
  • Linear sharpen 1 - this is basically Nintendo default, except recreated from scratch. Due to being added late, and not copypasted from an another broken swapped matrix, this one is not reversed, and thus there are no jagged edges (other than some weird ringing artifact on diagonals every 4-5 pixels or so). You can see the difference this makes if you keep holding X to preview this with Nintendo's default.
  • Darken crisp - this is Sono's crisp (original), but it's darkened by half. No pixel information is lost, all 64 shades are still displayed correctly. This was made before the Redshift patch, hence it's still there.
  • Darken Nintendo - just like its name says, this is the Nintendo default matrix, but darkened.
  • 4grid - these are experimental. This is an attempt at an LCD filter (search for "LCD shader" if you want to see examples), but on the 3DS this looks bad for some reason. It's most likely my fault for not understanding how this effect works.
The GBA scale filters are self-explainatory. They may also be reversed, I'm not sure.
You can't preview them due to an age-old bug in TWPatch scale matrix emulator, so you'll have to test them in-game.
But then again, GBA mode in TWPatch is kind of undocumented, intentionally. I'm rewriting AgbBg (and eventually AGB_FIRM as well), and there is also open_agb_firm, which is much more superior, use that instead.

As for the widescreen and GPU patch, they are technically very complicated.
Oversimplified, there are two ways in Nintendo's code to scale the capture card output: using the capture card's matrixes (basically the filter selection in TWPatch edits this), or using the GPU purely (the capture card upscaler is turned off, and the GPU upscales the image instead, using linear interpolation).
Nintendo actually wanted to implement GPU scaling, but the code is almost completely missing. Luckily, they left enough hints in the binary, so that I could painfully reimplement it. Sadly too much of the code is missing, so I had to resort to destructive patches to make it work.
Ideally we'd use both the scale matrixes *and* the GPU (upscale as high as we can using the scale matrixes, then *downscale* with the GPU) for the highest quality scaling, but I just simply can't figure out how to hack it into Nintendo's janky code. There is also not enough RAM for a higher-resolution image.

No, the GPU scale will always be blurry. If I switch from linear to nearest interpolation, due to how the GPU works, it will cause nasty jagged edges and mismatched pixels to be drawn due to rounding errors, so I can't do that. The reason it's blurrier than mine, is that the GPU has the highest quality linear interpolation (due to true 2D multi-sample, instead of fake 2x 1D interpolation), so this is how it is sadly.
 
  • Like
Reactions: G1fan

Vorty11

Member
Newcomer
Joined
Aug 6, 2014
Messages
12
Trophies
0
Age
42
XP
68
Country
United States
Yeah, you sadly need to re-patch it every time. The highlighted filter is used. Perhaps I should change how it works, as the filter selection was made when the patch menu did not exist, so it's just confusing now the way it is, that you must press A to enable the patches, but you must highlight the filter you want to use before pressing START, definitely confusing...
Many thanks for the followup Sono. This super thorough response should be pinned at the top of this thread now!

I grabbed TWPatch from Universal Updater and didn't notice those other filters, like 4grid. Is the UD version older than the one you posted in this thread here?

And if I switch filters, it sounds like I just need to save that TwlBg file again if I'm reading your response correctly. So at least I don't have to rename it and move it like for the widescreen patch.
 

Sono

cripple piss
Developer
Joined
Oct 16, 2015
Messages
2,822
Trophies
2
Location
home
XP
9,327
Country
Hungary
Many thanks for the followup Sono. This super thorough response should be pinned at the top of this thread now!

I grabbed TWPatch from Universal Updater and didn't notice those other filters, like 4grid. Is the UD version older than the one you posted in this thread here?

And if I switch filters, it sounds like I just need to save that TwlBg file again if I'm reading your response correctly. So at least I don't have to rename it and move it like for the widescreen patch.

Check again, it should be updated on Universal Updater now.
It is not the main distribution channel though, so I don't know if it's outdated or not. Sometimes it can be outdated, yeah.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: 24,000 hmmmm lol