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
    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 image matrix processor hardware, and made my own filters to show that sharp upscaling can be done.

    Edit: since the initial patch, I have been completely nuking DS mode, and have made a lot of discoveries since; including, but not limited to
    • scale matrix patching for a sharper image
    • CTR_Redshift support (blue light filtering in both DS and GBA mode)
    • screen swap for DS mode (the GBA only has a single screen, so it's nonswappable)
    • widescreen patching for both DS (256x192 --> 384x240) and GBA (240x160 --> 400x240) mode
    • button remapping (emulated)

    Widescreen SM64DS video (sorry for the 480p24 footage)

    Images

    Edit: the 1.5x patch is not useful anymore, so I have hidden it in a spoiler below.
    Useless 1.5x mode

    If you want to try these out without the patcher then you have to manually patch it yourself, because it's illegal to upload copyrighted material (and TWL_FIRM sure does contain copyrighted materials).

    Manual 1.25x scale patch
     
    Last edited by Sono, Jul 19, 2019
  2. Dartz150

    Dartz150 Hat Gurl Official Fan™

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

    Sono Modern slave

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

    Dartz150 Hat Gurl Official Fan™

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

    Sono Modern slave

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

    Sono Modern slave

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

    [​IMG]

    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.
     
    Tarmfot, Dartz150 and Ryccardo like this.
  7. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    Isn't 1.5x used by AGB_FIRM?

    Awesome that you are digging this stuff up. :yay:
     
    StrayGuitarist and Sono like this.
  8. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    Yeah, I heard that 1.5x is used by AGB_FIRM, but I didn't find any mention of GBA in the binary.
     
  9. SomeGamer

    SomeGamer GBAtemp Guru

    Member
    13
    Dec 19, 2014
    Antarctica
    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.
     
    Sono likes this.
  10. Extrasklep

    Extrasklep gbaTemp Fan

    Member
    6
    Aug 24, 2017
    Poland
    Browser’s Castle
    is this the secret project?
     
  11. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    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.
     
    Tarmfot, Dartz150 and SomeGamer like this.
  12. Robz8

    Robz8 Coolest of TWL

    pip Developer
    19
    Oct 1, 2010
    United States
    To users following the guide for 1.5x upscaling:
    Depending on what code.bin you have, the original 2 bytes' offset is either 0xC44 or 0xC46.
    The original bytes are "01 29".
     
    Last edited by Robz8, Jul 6, 2019
    Tarmfot, BOBdotEXE, zfreeman and 2 others like this.
  13. Dartz150

    Dartz150 Hat Gurl Official Fan™

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

    LoganK93 GBAtemp Advanced Fan

    Member
    7
    Dec 5, 2012
    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.
     
  15. Rahkeesh

    Rahkeesh GBAtemp Maniac

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

    Sono Modern slave

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

    I'm pretty sure that's a simple one or two byte patch. I'll look into it later.
     
    Robz8, ahezard and zfreeman like this.
  17. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    Aaaaaaaaaaaaaand, I did it! Crispy upscale filter :D

    Big images

    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 ¯\_(ツ)_/¯
     
    KoalaBoy, Pickle_Rick, Seriel and 8 others like this.
  18. SomeGamer

    SomeGamer GBAtemp Guru

    Member
    13
    Dec 19, 2014
    Antarctica
    Nice! You can finally go and actually play the thing... right?
     
  19. Sono
    OP

    Sono Modern slave

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

    SomeGamer GBAtemp Guru

    Member
    13
    Dec 19, 2014
    Antarctica
    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.
     
Quick Reply
Draft saved Draft deleted
Loading...