TWPatcher - DS(i) mode screen filters and patches

Sono Jul 4, 2019.

  1. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    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.
     
    Reynardine likes this.
  2. Dartz150

    Dartz150 Hat Gurl Official Fan™

    Member
    10
    May 5, 2010
    Mexico
    Under your bed
    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.
     
    Reynardine likes this.
  3. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    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.
     
    Dartz150 likes this.
  4. EduAAA

    EduAAA Member

    Newcomer
    1
    Sep 3, 2017
    Spain
    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, Sep 10, 2019
    Dartz150 likes this.
  5. Dartz150

    Dartz150 Hat Gurl Official Fan™

    Member
    10
    May 5, 2010
    Mexico
    Under your bed
    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.
     
  6. EduAAA

    EduAAA Member

    Newcomer
    1
    Sep 3, 2017
    Spain
    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.
     
  7. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    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.
     
  8. EduAAA

    EduAAA Member

    Newcomer
    1
    Sep 3, 2017
    Spain
    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, Sep 10, 2019
    Dartz150 likes this.
  9. piratesephiroth

    piratesephiroth I wish I could read

    Member
    11
    Sep 5, 2013
    Brazil
    The colors look a bit washed out in the XL models, possibly because of the larger horizontal gaps between the lines of pixels.
     
    Rahkeesh likes this.
  10. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    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.
     
  11. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    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.

    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.

    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, Sep 10, 2019
    Dartz150 likes this.
  12. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    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.
     
  13. Dartz150

    Dartz150 Hat Gurl Official Fan™

    Member
    10
    May 5, 2010
    Mexico
    Under your bed
    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.
     
  14. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    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.

    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.
     
  15. Dartz150

    Dartz150 Hat Gurl Official Fan™

    Member
    10
    May 5, 2010
    Mexico
    Under your bed
    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.
     
  16. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    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.
     
    Dartz150 likes this.
  17. ghjfdtg

    ghjfdtg GBAtemp Fan

    Member
    6
    Jul 13, 2014
    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.
     
    Sono likes this.
  18. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    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.
     
  19. ghjfdtg

    ghjfdtg GBAtemp Fan

    Member
    6
    Jul 13, 2014
    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.
     
    Sono likes this.
  20. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    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.
     
Quick Reply
Draft saved Draft deleted
Loading...