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

  • Thread starter Sono
  • Start date
  • Views 479,260
  • Replies 2,006
  • Likes 90

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

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

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

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

    Votes: 8 7.5%
  • No, because I only use DS and DSi mode

    Votes: 5 4.7%

  • Total voters
    106

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,463
Trophies
2
Location
rehabilitation center
XP
5,488
Country
Hungary
Based on the 3 filters (1x (START+SELECT), 1.25x (default), and 1.5x (used only in GBA mode)) found inside TWL_FIRM, I reverse engineered most of the capture card's image processor (used to capture DS and GBA screens), and made my own filters to show that sharp upscaling can be done.

But that's not all! Since the initial patcher (which was only able to change the upscaling filter), a lot of work has been done:
  • Remove the DPAD input filter, so you can press LEFT+RIGHT and UP+DOWN without it being blocked, so you can enjoy glitches exclusive to this gameplay mechanic ;)
  • Blue light filtering thanks to CTR_Redshift
  • Screen swap for DS mode (the GBA only has a single screen, so it's not swappable)
  • Widescreen patching for both DS (4:3 --> 16:10) and GBA (15:10 --> 15:9) mode
  • ARM11 <--> ARM7 communication with rtcom (discovered by @Gericom)
    • Currently only GBARunner2 utilizes this for gyroscope emulation when playing WarioWare Twisted!, but any developer and romhacker can use this for anything which needs 3DS hardware access
  • Use GPU for upscaling
    • It looks much better than the default upscaling, but it's too blurry for some people
    • It can also pose a health hazard for people with nervous system problems who get weird spazms and epilleptic effects, so use with care!
With a lot of help, love, and support from the community, there are useful use cases for the above patches:
  • TWiLightMenu++ lets you play games which have widescreen patches... in widescreen!
    • It's also possible thanks to everyone who are actively making those patches!
  • GBARunner2 uses rtcom to enable us to be able to play WarioWare Twisted! utilizing the gyroscope built into the 3DS
There are also a few patches for developers too:
  • Possible to patch Process9, Kernel11Loader, and Kernel11
  • Includes a Kernel11 patch which reinstalls exception handlers, so you can debug your payloads easier


ce64b7ec17.jpg

7b2c70e702.jpg

53f1d365bb.jpg

a215fe4708.jpg

aa87ea1b0f.jpg

364ace4046.jpg

d66eb6a763.jpg

30dbf7007b.jpg

4205de0403.jpg

a7a62e196e.jpg

f6557071b2.jpg

40909d9572.jpg

If you want to see all scale matrixes, @Halvorsen has used a capture card to capture how it looks like on real hardware.
7W9LMPP.png

There are no downloads anymore. Sorry for the inconvenience.
Please use community-provided mirrors.

 
Last edited by Sono,

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,463
Trophies
2
Location
rehabilitation center
XP
5,488
Country
Hungary
What makes this different that the current scale method? Does it look better than the blurry and washed out filter that TWL_FIRM normally applies?

As you can see, the bottom-right of the screen is cut off, because 384x288 is bigger than 320x240. But since that resolution is double of the DS, the image doesn't look blurry.

Upon closer inspection, there is sadly still interpolation, but because the scaling is integer, the image looks REALLY crisp.
 

Dartz150

Yet another Onii-chan
Member
Joined
May 5, 2010
Messages
2,202
Trophies
1
Age
29
Location
Over your head
XP
3,575
Country
Mexico
As you can see, the bottom-right of the screen is cut off, because 384x288 is bigger than 320x240. But since that resolution is double of the DS, the image doesn't look blurry.

Upon closer inspection, there is sadly still interpolation, but because the scaling is integer, the image looks REALLY crisp.

I see, and yeah, the main reason behind the blurriness in the standard scaling method is because the scale is not integer and is difficult to get accurate pixel draw with that setup alone.

The thing is that this opens the possibility of (maybe) implementation or different scaling methods, I remember back in 2015 that someone asked if it was possible to hack different filtering methods and custom frames for native resolution to TWL_FIRM or something like that. Do you think it could be possible?
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,463
Trophies
2
Location
rehabilitation center
XP
5,488
Country
Hungary
I see, and yeah, the main reason behind the blurriness in the standard scaling method is because the scale is not integer and is difficult to get accurate pixel draw with that setup alone.

The thing is that this opens the possibility of (maybe) implementation or different scaling methods, I remember back in 2015 that someone asked if it was possible to hack different filtering methods and custom frames for native resolution to TWL_FIRM or something like that. Do you think it could be possible?

I think it should be possible if my observations are correct.

But even if I could get the scaling removed, the scaling would look absolutely horrible due to how the PICA upscales textures.
 
  • Like
Reactions: Dartz150

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,463
Trophies
2
Location
rehabilitation center
XP
5,488
Country
Hungary
It turns out that LgyFb is actually a matrix unit for scaling images. I found the 3 kernels associated with each upscale mode (1x, 1.25x (default), and 1.5x)

fad6b26663.png


Just by looking at the image, I think you can already see why 1.25x scaling (the default scaling without pressing START+SELECT) looks so horrible. I have no idea what these matrixes are, but it's pretty clear that the 1.25x scaling matrix is doing something weird.
 

SomeGamer

Well-Known Member
Member
Joined
Dec 19, 2014
Messages
6,822
Trophies
1
XP
4,390
Country
Hungary
No idea why anyone would use this (and why Nintendo left the code in) but can't deny it looks much better than the original.
 
  • Like
Reactions: Sono

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,463
Trophies
2
Location
rehabilitation center
XP
5,488
Country
Hungary
No idea why anyone would use this (and why Nintendo left the code in) but can't deny it looks much better than the original.

According to almost everyone, it might be indeed a leftover from AGB_FIRM. But it's weird, because 3dbrew said somewhere that TwlBg is the same on both TWL_FIRM and AGB_FIRM :/

is this the secret project?

Nope, this is "the experiment". The secret project is very far away.
 

Dartz150

Yet another Onii-chan
Member
Joined
May 5, 2010
Messages
2,202
Trophies
1
Age
29
Location
Over your head
XP
3,575
Country
Mexico
According to almost everyone, it might be indeed a leftover from AGB_FIRM. But it's weird, because 3dbrew said somewhere that TwlBg is the same on both TWL_FIRM and AGB_FIRM :/



Nope, this is "the experiment". The secret project is very far away.
Thank you for you explanation, looking forward to your research and what advantages/improvements flourish from it. I Wonder what that secret project may be. I suppose is big, hence it being secret :ninja:
 
  • Like
Reactions: Sono

LoganK93

Well-Known Member
Member
Joined
Dec 5, 2012
Messages
670
Trophies
0
Age
28
XP
1,536
Country
United States
I'm an idiot. Could this ever lead to widescreen on 3DS with DS games? Even if stretched I'd love to finally kill those black bars.
 

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,029
Trophies
1
Age
40
XP
2,394
Country
United States
At a minimum I'd guess you could swap which is the default and which start/select activates? For people who would prefer the default to be no scaling, for instance.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,463
Trophies
2
Location
rehabilitation center
XP
5,488
Country
Hungary
I'm an idiot. Could this ever lead to widescreen on 3DS with DS games? Even if stretched I'd love to finally kill those black bars.

Sadly not yet, because the aspect ratio has to match. Once I reverse engineer the image matrix hardware more, it might be possible, but it would require extreme patching due to space limitations, and for that I would have to disable the other scaling modes.

At a minimum I'd guess you could swap which is the default and which start/select activates? For people who would prefer the default to be no scaling, for instance.

I'm pretty sure that's a simple one or two byte patch. I'll look into it later.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,463
Trophies
2
Location
rehabilitation center
XP
5,488
Country
Hungary
Aaaaaaaaaaaaaand, I did it! Crispy upscale filter :D

ce64b7ec17.jpg

7b2c70e702.jpg

It turns out that I was an idiot, and was writing invalid filters into the file which hardlocked everything. That's what I get for manually entering the bytes into a hex editor without a tool autogenerating them for me ¯\_(ツ)_/¯
 

SomeGamer

Well-Known Member
Member
Joined
Dec 19, 2014
Messages
6,822
Trophies
1
XP
4,390
Country
Hungary
Aaaaaaaaaaaaaand, I did it! Crispy upscale filter :D

ce64b7ec17.jpg

7b2c70e702.jpg

It turns out that I was an idiot, and was writing invalid filters into the file which hardlocked everything. That's what I get for manually entering the bytes into a hex editor without a tool autogenerating them for me ¯\_(ツ)_/¯
Nice! You can finally go and actually play the thing... right?
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,463
Trophies
2
Location
rehabilitation center
XP
5,488
Country
Hungary
Nice! You can finally go and actually play the thing... right?

Yeah uh... I would release the patch, but there is a small problem: TwlBg contains copyrighted material, and it's impossible to patch compressed code without unpacking and repacking it completely.

My idea is to include a patcher homebrew which dumps TwlBg, unpacks it, patches it, then places it in /luma/sysmodules/TwlBg.cxi, and that way you can even specify your own filters.
You can do gaussian filters and double vision with this image processing matrix hardware :blink:
 

SomeGamer

Well-Known Member
Member
Joined
Dec 19, 2014
Messages
6,822
Trophies
1
XP
4,390
Country
Hungary
My idea is to include a patcher homebrew which dumps TwlBg, unpacks it, patches it, then places it in /luma/sysmodules/TwlBg.cxi, and that way you can even specify your own filters.
That'd be the most user-friendly way. IMO you could release some manual patching instructions in the meantime if it isn't a ton of values but it's your call ultimately.
 
General chit-chat
Help Users
    kenenthk @ kenenthk: @WG481, We have a deep gay love for each other we're both in the closet about that's why