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

  • Thread starter Sono
  • Start date
  • Views 734,472
  • Replies 2,420
  • Likes 100

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,800
Trophies
2
Location
home
XP
9,221
Country
Hungary
Yep I know. Trouble is people use this to explain their chances of winning the lottery too. Which sounds about as likely since we don't have any known case of AGB patching failing?

I mean yeah, its safer to treat it as experimental at first, but saying 50% makes it sound much scarier than the reality. I assumed it was some very rough estimate based on tester reports, but it seems not to be.

I don't have any known case of this particular patch failing.

Also, this is just the "initial hook" patch (invisible, and NOT toggle-able manually). If I can't install this patch then you can't have anything else other than code-only patches (stuff like basic scale matrix alteration, section1 of the CPad patches (which disables CPad if there is not a section2 installed by the initial hook), and other generic TwlBg patches).

It might be possible though that AgbBg will always be patchable because to my knowledge it hasn't been updated in ages.
 
  • Like
Reactions: Reynardine

DSoryu

GBA/NDS Maniac
Member
Joined
May 5, 2010
Messages
2,348
Trophies
2
Location
In my house
XP
4,711
Country
Mexico
I have to ask this, since it has been bugging me for a while.
Something apparently caused as a side effect from the scaling are washed out colors/palettes on all NDS games. So would it be possible to patch in a LUT to increase contrast at will at the resulting scaled displays? I know this is something completely different, but for example, I believe that mGBA uses something like that to restore washed out colors on some pre-SP model GBA games, having in the options a "dark/darker screen" setting, but instead of applying a dark filter, it increases contrast, hue and saturation.
 
  • Like
Reactions: Reynardine

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,800
Trophies
2
Location
home
XP
9,221
Country
Hungary
I have to ask this, since it has been bugging me for a while.
Something apparently caused as a side effect from the scaling are washed out colors/palettes on all NDS games. So would it be possible to patch in a LUT to increase contrast at will at the resulting scaled displays? I know this is something completely different, but for example, I believe that mGBA uses something like that to restore washed out colors on some pre-SP model GBA games, having in the options a "dark/darker screen" setting, but instead of applying a dark filter, it increases contrast, hue and saturation.

The washing out is probably the result of incorrect blending. Since it's impossible to do exponentiation and sqrt without multiple passes and some clever hacking, the colors will be always wrong on blending edges.

Also yes, it's possible to do LUT uploads as long as it's never going downwards. If it's going downwards then it gets so big that no other patches work due to space limitations.

I'd say I'll probably investigate that once I figure out how the "magic HDR" bit works in the LCD controller.

It's also possible without the "magic HDR" bit, but the LUT is only 8bits in resolution, so you're guaranteed to get color collisions. It also doesn't help that the screen is partially dithered (bit0 flickers on and off really fast), and that the DS screens are originally RGB666, so bit1 even goes unused, further limiting the actual LUT entries which get used. I guess this allows for a lower chance of LUT collisions, allowing me to use 1.5 more bits to output.
 
  • Like
Reactions: DSoryu

EduAAA

Well-Known Member
Member
Joined
Sep 3, 2017
Messages
104
Trophies
0
Age
38
XP
261
Country
Spain
The washing out is probably the result of incorrect blending. Since it's impossible to do exponentiation and sqrt without multiple passes and some clever hacking, the colors will be always wrong on blending edges.

Also yes, it's possible to do LUT uploads as long as it's never going downwards. If it's going downwards then it gets so big that no other patches work due to space limitations.

I'd say I'll probably investigate that once I figure out how the "magic HDR" bit works in the LCD controller.

It's also possible without the "magic HDR" bit, but the LUT is only 8bits in resolution, so you're guaranteed to get color collisions. It also doesn't help that the screen is partially dithered (bit0 flickers on and off really fast), and that the DS screens are originally RGB666, so bit1 even goes unused, further limiting the actual LUT entries which get used. I guess this allows for a lower chance of LUT collisions, allowing me to use 1.5 more bits to output.

About this topic, first gba models don't have backlight, so in order to compensate that, games have over satured gamma colors.

This magic shader/filter, makes color look much better and the way gba games should look : https://github.com/mrgriscom/emu/bl.../shaders/shaders_glsl/handheld/gba-color.glsl

Also, I think you are behind the blue light filters included on luma 10.0.1, do you know if more filters could be added, for example filters like 3ds retroarch uses? ( there is a filter called Normal2x, it renders the image with double resolution then downscales it to normal resolution, making gbc games using full vertical resolution looking much better than the official emulator that looks too much blurry if you don't use pixel perfect mode )

You can see it here: https://github.com/libretro/RetroArch/pull/7518

Maybe it is easier to port those filters to work outside retroarch app in order to have better looking image ? I don't know if it is possible, just a question

BTW, mgba already has an option to show games at top//bottom, pixel perfect, bilinear, etc, it is open source maybe it can help you with that too:

https://github.com/mgba-emu/mgba
 
Last edited by EduAAA,
  • Like
Reactions: DSoryu

DSoryu

GBA/NDS Maniac
Member
Joined
May 5, 2010
Messages
2,348
Trophies
2
Location
In my house
XP
4,711
Country
Mexico
About this topic, first gba models don't have backlight, so in order to compensate that, games have over satured gamma colors.

This magic shader/filter, makes color look much better and the way gba games should look : https://github.com/mrgriscom/emu/bl.../shaders/shaders_glsl/handheld/gba-color.glsl

Also, I think you are behind the blue light filters included on luma 10.0.1, do you know if more filters could be added, for example filters like 3ds retroarch uses? ( there is a filter called Normal2x, it renders the image with double resolution then downscales it to normal resolution, making gbc games using full vertical resolution looking much better than the official emulator that looks too much blurry if you don't use pixel perfect mode )

You can see it here: https://github.com/libretro/RetroArch/pull/7518

Maybe it is easier to port those filters to work outside retroarch app in order to have better looking image ? I don't know if it is possible, just a question

BTW, mgba already has an option to show games at top//bottom, pixel perfect, bilinear, etc, it is open source maybe it can help you with that too:

https://github.com/mgba-emu/mgba

Despite this info being useful and interesting, I believe that Sono's approach with TWL_FIRM works completely different, correct me if I'm wrong.
 

EduAAA

Well-Known Member
Member
Joined
Sep 3, 2017
Messages
104
Trophies
0
Age
38
XP
261
Country
Spain
Despite this info being useful and interesting, I believe that Sono's approach with TWL_FIRM works completely different, correct me if I'm wrong.
completely, but maybe something can be useful, I mean, twl_firm / agb_firm don't use all 3Ds ( of course not even new 3ds ) cpu/gpu performance power, but if im right, twl_firm runs ds games at ds speed but has access to dsi speed, so maybe, that extra power can be used to apply some filters?) agb_firm too I think.

But, even if not possible to use filters while using twl_firm / agb_firm, it would be awesome to have some filters for 3ds games and vc games, the same way we can use those blue filters. For example, have a sharper image, add scanlines or whatever... I know 3ds can't use gl shaders, but well, there are other for example the ones 3ds retroarch port use.
 

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,248
Country
United States
I never noticed a big difference between scaled and non-scaled NDS games in terms of colors on 3DS, so I'm not sure its the scaling itself that can be faulted. I don't think color fringing is the issue you are referring to either.

I would also guess there's some kind of adjustment going on for the differing color ranges on the system, for instance GBA is only 555 but without any dark filter set in the VC itself it gets plenty bright while keeping blacks about as low as they can go. It also looks the same color wise as homebrew emulators on the system.

If you're comparing to a DSi/XL I think the color saturation is just plain higher on that than even IPS 3DS, you get far bolder colors out of that than on any 3DS game. In other words the 3DS display itself just tends to be less saturated.
 

EduAAA

Well-Known Member
Member
Joined
Sep 3, 2017
Messages
104
Trophies
0
Age
38
XP
261
Country
Spain
I never noticed a big difference between scaled and non-scaled NDS games in terms of colors on 3DS, so I'm not sure its the scaling itself that can be faulted. I don't think color fringing is the issue you are referring to either.

I would also guess there's some kind of adjustment going on for the differing color ranges on the system, for instance GBA is only 555 but without any dark filter set in the VC itself it gets plenty bright while keeping blacks about as low as they can go. It also looks the same color wise as homebrew emulators on the system.

If you're comparing to a DSi/XL I think the color saturation is just plain higher on that than even IPS 3DS, you get far bolder colors out of that than on any 3DS game. In other words the 3DS display itself just tends to be less saturated.

Still gba games are way over saturated playing on 3Ds:

See the difference:

http://emulation.gametechwiki.com/index.php/File:1406913527173-1-.png

here the explanation:

http://emulation.gametechwiki.com/index.php/Game_Boy_Advance_emulators#Oversaturation

Edit:

If you wanna get mad and never feel satisfied again with the image quality of gba/nds games, you can take a look at this: https://forums.libretro.com/t/real-gba-and-ds-phat-colors/1540/159
 
Last edited by EduAAA,
  • Like
Reactions: DSoryu

piratesephiroth

I wish I could read
Member
Joined
Sep 5, 2013
Messages
3,453
Trophies
2
Age
103
XP
3,228
Country
Brazil
I never noticed a big difference between scaled and non-scaled NDS games in terms of colors on 3DS, so I'm not sure its the scaling itself that can be faulted. I don't think color fringing is the issue you are referring to either.
The colors look a bit washed out in the XL models, possibly because of the larger horizontal gaps between the lines of pixels.
 
  • Like
Reactions: Rahkeesh

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,248
Country
United States
Still gba games are way over saturated playing on 3Ds:

This is a separate issue from color depth, the "dark filter" and ghosting amount you can adjust on the injector is Nintendo's solution to emulating physical display qualities.

Usually I like max brightness anyway because playing in a bright area on 3DS can still be a struggle as is.

What would be really awesome is if we could adjust the backlight scale, since the parallax barrier will never be engaged in AGB/TWL there should be untapped brightness levels. I'm guessing that the system governing these is different from the increasingly "secure" one on the 3DS firmware so maybe there's some chance it could be changed if discovered.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,800
Trophies
2
Location
home
XP
9,221
Country
Hungary
About this topic, first gba models don't have backlight, so in order to compensate that, games have over satured gamma colors.

This magic shader/filter, makes color look much better and the way gba games should look : https://github.com/mrgriscom/emu/bl.../shaders/shaders_glsl/handheld/gba-color.glsl

Also, I think you are behind the blue light filters included on luma 10.0.1, do you know if more filters could be added, for example filters like 3ds retroarch uses? ( there is a filter called Normal2x, it renders the image with double resolution then downscales it to normal resolution, making gbc games using full vertical resolution looking much better than the official emulator that looks too much blurry if you don't use pixel perfect mode )

You can see it here: https://github.com/libretro/RetroArch/pull/7518

Maybe it is easier to port those filters to work outside retroarch app in order to have better looking image ? I don't know if it is possible, just a question

BTW, mgba already has an option to show games at top//bottom, pixel perfect, bilinear, etc, it is open source maybe it can help you with that too:

https://github.com/mgba-emu/mgba
Despite this info being useful and interesting, I believe that Sono's approach with TWL_FIRM works completely different, correct me if I'm wrong.

I can't even read that awful reverse-engineered -looking glsl source, but I can already tell that it's not possible. Not only can the matrix unit not do anything other than multiplication and addition (averaging, basically), but the PICA200 doesn't have a reprogrammable fragment unit either, so there is no way we can do the above.

This is not a software issue, but a completely hardware issue.

And no, I can't do this in software, because there is just not enough time to filter the image manually using CPU power.

completely, but maybe something can be useful, I mean, twl_firm / agb_firm don't use all 3Ds ( of course not even new 3ds ) cpu/gpu performance power, but if im right, twl_firm runs ds games at ds speed but has access to dsi speed, so maybe, that extra power can be used to apply some filters?) agb_firm too I think.

But, even if not possible to use filters while using twl_firm / agb_firm, it would be awesome to have some filters for 3ds games and vc games, the same way we can use those blue filters. For example, have a sharper image, add scanlines or whatever... I know 3ds can't use gl shaders, but well, there are other for example the ones 3ds retroarch port use.

TwlBg/AgbBg is almost completely passive. The entire code is tied to a simple wait for VSync, and it can't be disturbed without completely glitching out the graphics and softlocking ARM11.
Also, ARM11 still runs at 268111856Hz, which is double of DSi ARM9, which is double of DS ARM9, which is afaik double of DS ARM7, which is double of GBA? It doesn't matter tho', because once the ARM9 is in DS mode, the ARM11 dies when you try to access any memory used by the DS, because the memory is PHYSICALLY detached from the ARM11 until reboot.

I don't know about emulated VC games though... I know that the PICA200's fragment unit is not reprogrammable, so you can't use pixel shaders, and vertex shaders are useless in this case.

This is a separate issue from color depth, the "dark filter" and ghosting amount you can adjust on the injector is Nintendo's solution to emulating physical display qualities.

Usually I like max brightness anyway because playing in a bright area on 3DS can still be a struggle as is.

What would be really awesome is if we could adjust the backlight scale, since the parallax barrier will never be engaged in AGB/TWL there should be untapped brightness levels. I'm guessing that the system governing these is different from the increasingly "secure" one on the 3DS firmware so maybe there's some chance it could be changed if discovered.

I don't know about a "dark filter", but that sounds like something you would do in a LUT.

You can adjust brightness from the pause dialog by holding either START or SELECT, and using the DPAD.
 
Last edited by Sono,
  • Like
Reactions: DSoryu

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,248
Country
United States
You can adjust brightness from the pause dialog by holding either START or SELECT, and using the DPAD.

Yes I know, but this uses something pretty close to the 3DS' typical brightness levels with the parallax barrier off. The thing that would be nice is to push the backlight higher on 3DS models towards where it would be with the barrier on. You mentioned trouble doing this with recent firmware on the 3DS side, I just wondered whether the situation might be different in AGB/TWL.
 

DSoryu

GBA/NDS Maniac
Member
Joined
May 5, 2010
Messages
2,348
Trophies
2
Location
In my house
XP
4,711
Country
Mexico
Yes I know, but this uses something pretty close to the 3DS' typical brightness levels with the parallax barrier off. The thing that would be nice is to push the backlight higher on 3DS models towards where it would be with the barrier on. You mentioned trouble doing this with recent firmware on the 3DS side, I just wondered whether the situation might be different in AGB/TWL.

Sono mentioned a while back that doing this breaks MCU badly and is better to avoid any hack to the brightness levels, but that was quite some time ago, I don't know the current status.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,800
Trophies
2
Location
home
XP
9,221
Country
Hungary
Yes I know, but this uses something pretty close to the 3DS' typical brightness levels with the parallax barrier off. The thing that would be nice is to push the backlight higher on 3DS models towards where it would be with the barrier on. You mentioned trouble doing this with recent firmware on the 3DS side, I just wondered whether the situation might be different in AGB/TWL.

That's a good question, considering that TwlBg/AgbBg is running a stripped-down monolithic version of the 3DS OS. I'll look into it.

Sono mentioned a while back that doing this breaks MCU badly and is better to avoid any hack to the brightness levels, but that was quite some time ago, I don't know the current status.

Can you please find where I said that? The LCD brightness is adjusted via LCD regs, and you can go up to 4095 (around 272 being level5 with 3D off(?)), it doesn't involve the MCU. However, the increased voltage causes a power draw higher than intended, so it might cause hardware faults in the long run, overdriving the backlight panel.
 

DSoryu

GBA/NDS Maniac
Member
Joined
May 5, 2010
Messages
2,348
Trophies
2
Location
In my house
XP
4,711
Country
Mexico
Can you please find where I said that? The LCD brightness is adjusted via LCD regs, and you can go up to 4095 (around 272 being level5 with 3D off(?)), it doesn't involve the MCU. However, the increased voltage causes a power draw higher than intended, so it might cause hardware faults in the long run, overdriving the backlight panel.

Ok! I just need to remebere where I waw that and will search for it :P, meanwhile, I could mention that I remember that you mentioned something of the sort when someone asked you about the custom brigthness settings for Rosalina.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,800
Trophies
2
Location
home
XP
9,221
Country
Hungary
Ok! I just need to remebere where I waw that and will search for it :P, meanwhile, I could mention that I remember that you mentioned something of the sort when someone asked you about the custom brigthness settings for Rosalina.

Yeah, on new3DS only(?) you have to patch gsp, or else the brightness will reset to what it was before. The problem is that those gsp patches crash gsp, and I don't know anyone who has worked on those patches since.
 
  • Like
Reactions: DSoryu

ghjfdtg

Well-Known Member
Member
Joined
Jul 13, 2014
Messages
1,350
Trophies
1
XP
3,236
Country
Don't increase the backlight level beyond the equivalent of level 5 on home menu. It's not meant to get that much power and we don't know where the safe limit is other than what Nintendo uses as maximum.
 
  • Like
Reactions: Sono

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,800
Trophies
2
Location
home
XP
9,221
Country
Hungary
Don't increase the backlight level beyond the equivalent of level 5 on home menu. It's not meant to get that much power and we don't know where the safe limit is other than what Nintendo uses as maximum.

I tested on my old3DS, and I don't know if it was my face feeling as if a miniature sun was shining into my face, or something was actually giving out a very quiet very high-pitched sound when I cranked up the brightness up to 4095. Either way, past ~380-400 you get the same appearent brightness as 4095, so it's pointless to push it past that for those 1-2 extra unnoticable brightness... units.
 

ghjfdtg

Well-Known Member
Member
Joined
Jul 13, 2014
Messages
1,350
Trophies
1
XP
3,236
Country
Yeah, at a certain power level you won't see a difference but the LEDs start converting all the superflous energy into heat. I don't know where i read it but someone set the brighness level reg all the way to max and his 3DS heated up quite a bit.
 
  • Like
Reactions: Sono

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,800
Trophies
2
Location
home
XP
9,221
Country
Hungary
Yeah, at a certain power level you won't see a difference but the LEDs start converting all the superflous energy into heat. I don't know where i read it but someone set the brighness level reg all the way to max and his 3DS heated up quite a bit.

I think it was me. The display was getting feel-able, but nothing major. It certainly wasn't as warm as the CPU after using it for 20m.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    LeoTCK @ LeoTCK: yes for nearly a month i was officially a wanted fugitive, until yesterday when it ended