TWPatcher - DS(i) mode screen filters and patches

Discussion in '3DS - Homebrew Development and Emulators' started by Sono, Jul 4, 2019.

  1. Robz8

    Robz8 Coolest of TWL

    pip Developer
    19
    Oct 1, 2010
    United States
    Redo all the widescreen steps exactly.
     
  2. PokeNev
    This message by PokeNev has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  3. VMM
    This message by VMM has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  4. PokeNev

    PokeNev GBAtemp Regular

    Member
    2
    Nov 11, 2018
    United States
    I am dumb, I called a folder "twbg” when it was supposed to be called “twlbg” I missed an L but in my defense, it’s easy to miss

    One more thing, is there a list of games that work with widescreen? Cause I’ve tested a few games, and so far only super Mario bros 64 is working (mostly cause I have obscure games)
     
    Last edited by PokeNev, Sep 2, 2019
    Dartz150 likes this.
  5. Robz8

    Robz8 Coolest of TWL

    pip Developer
    19
    Oct 1, 2010
    United States
    It's in the "3DS - CFW users" folder.
     
  6. PokeNev
    This message by PokeNev has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  7. Sono
    This message by Sono has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  8. PokeNev
    This message by PokeNev has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  9. Sono
    This message by Sono has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  10. PokeNev
    This message by PokeNev has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  11. Sono
    This message by Sono has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  12. PokeNev
    This message by PokeNev has been removed from public view by porkiewpyne, Sep 2, 2019, Reason: Offtopic.
    Sep 2, 2019
  13. PokeNev

    PokeNev GBAtemp Regular

    Member
    2
    Nov 11, 2018
    United States
    I’m sorry but I REALLY can’t find it
     
  14. Robz8

    Robz8 Coolest of TWL

    pip Developer
    19
    Oct 1, 2010
    United States
    ...in TWiLight Menu++'s .7z file?
     
  15. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    I think I stumbled on something close? to linear interpolation for GBA. It's maybe every so slightly blurrier than bilinear options in Retroarch and MGBA emulators, so not ideal but, progress maybe?

    If you're curious, get code.bin out of agbbg.cxi and search for this string:

    Code:
    0000 0020 0040 0000 0020 0040 0040 0020 0000 0040 0020 0000
    replace with

    Code:
    0010 0020 0030 0010 0020 0030 0030 0020 0010 0030 0020 0010
     
    evertonstz, Raylight and Dartz150 like this.
  16. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    I think I've figured out a sharpen effect for GBA. Here it is applied on top of that linear? interpolation:

    replace
    Code:
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 40 00 00 00 20 00 40 00 40 00 20 00 00 00 40 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    
    with

    Code:
    FB 00 F6 00 F1 00 FB 00 F6 00 F1 00 15 00 2A 00 3F 00 15 00 2A 00 3F 00 3F 00 2A 00 15 00 3F 00 2A 00 15 00 F1 00 F6 00 FB 00 F1 00 F6 00 FB
    I have to say in general I don't like it as much as I'd hope. It feels a bit like Nintendo DS scaling, its a touch too blurry but I'm already hitting sharpening artifacts that I don't want more of. Although I could be doing something wrong here with the sharpening maths. If anyone is REALLY curious I can explain how I mathed it, in case you want to tweak it further.

    I'm instead liking the look of a "toned-down" crispness, which is simply a middle ground between Nintendo default and linear interpolation. It has some more shape distortion versus the sharpened linear interpolation, but still feels clearer overall, while being a little less distorted than Nintendo default.

    Code:
    00 00 00 00 00 00 00 00 00 00 00 00 06 00 20 00 3A 00 06 00 20 00 3A 00 3A 00 20 00 06 00 3A 00 20 00 06 00 00 00 00 00 00 00 00 00 00 00 00
    Maybe combining the two approaches would yield the best results, I might try that later.
     
  17. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    If you want to just tweak the GBA crispiness/smoothness, just replace in code.bin of agbbg.cxi:

    Code:
     0000 0020 0040 0000 0020 0040 0040 0020 0000 0040 0020 0000
    with

    Code:
     00XX 0020 00YY 00XX 0020 00YY 00YY 0020 00XX 00YY 0020 00XX
    Where XX is between x0 and x20 and YY is betweeen x20 and x40, and together these should also add up to x40.

    X=0 Y=40 is the default super crisp, often chunky scaling
    X=10 Y=30 gives you a smooth effect like bilinear interpolation
    X=20 Y=20 makes everything flat and super blurry

    X=07 Y=39 is my current go-to. Its about the minimum crispness that keeps high-contrast text distinct and easy to read. Something closer to this should've been the Nintendo default considering what they picked for DS scaling..

    I'm SO much happier using AGB_FIRM now with these settings. Big thanks again to Sono for doing the heavy lifting of finding this stuff, now I got something to hold me over until he gets his patcher finished!
     
  18. evertonstz

    evertonstz Advanced Member

    Newcomer
    2
    Jan 5, 2019
    Brazil
    Tbh I was monitoring this thread just in hope someone would tweak the gba scaling, I'm kinda dumb messing around with hex, so what are the chances you release a cia patcher like Sonos did initially with these tweaks?
     
    Last edited by evertonstz, Sep 5, 2019
  19. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    Zero, I haven't touched any 3DS dev environment let alone programmed in a while. Maybe I could write instructions for how to make the changes, but it does involve a few command line tools and then the hex editor.

    Sono is developing GBA patching in his latest tool so that should eventually be able to handle it.
     
    Last edited by Rahkeesh, Sep 5, 2019
    evertonstz likes this.
  20. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    You probably don't care about this, so don't open

    And now for stuff related to TWPatch itself:

    Now that my brain is starting to wake up, a few nights ago (probably yesterday) I thought of a possible optimization for the compressor, so if it works out then it should not take 6mins anymore to compress on old3DS. After doing some calculations, it seems like that I'm double-trashing the miniscule 16k CPU data cache (L1?), hence it's very slow on the 3DS. However, it's also slow on my desktop CPU, which has much more cache than that poor ARMv6K from 2010, so there are definitely some code optimizations to do. I think a rewrite is better, because looking at it shows clear signs that an idiot made this (me), and it's so unoptimized that it brings sad tears to my eye.

    The above also goes for UI responsiveness. For some reason I tried to make a low-level matrix hardware emulator, which is completely useless, because we want speed, not 100% accuracy (not that you can really mess up simple mathematical calculations, becaues if it doesn't match the original then it's wrong, and period), so that's also going to be rewritten. And besides, there is even a bug in it, which causes the image edges to be distorted :P

    Oh, and the UI is horrible. I think I'll reuse some code from an unreleased(?) LCD tester homebrew of mine, which has some really fancy (text-based) sliders. However, I have already ran out of buttons (not being able to use L, R, and touch is really limiting me here, because people break them all the time, or they just break themselves), so an UI redesign is required. It will not be *that* different, but the controls will change.

    As for the biggest "selling point", the scale matrixes: I'm starting to understand the math beind them. Once I can get Visual Studio 2010 working (yes, on Linux) then I'll experiment with them, and hopefully I'll be able to autogenerate them independently of the scaling ratio, so I'll only need to store parameters instead of the whole matrix, allowing me to reuse the same scale matrix parameters for GBA. Oh, and scale matrix loading from SD, because the HxD method sucks, and crashes for some reason if you use specific values.

    And on a last note, I think I'll unlock GBA patches as experimental. I don't guarantee they'll work for you. In fact, they have a 50% of not being compatible with your installed AgbBg version, so if you're desperate on wanting to use them, then you might need to downgrade your AgbBg, which is NOT recommended. I can't do too much about this, because there is just no place where I can execute my own code. I have space for my own code, but I just don't have a place where I can call it from.

    If I can setup my devenv today then this should take a few days or 1-2 weeks if no problems arise.
     
  21. tatundria

    tatundria GBAtemp Fan

    Member
    5
    Feb 24, 2009
    Argentina
    where is the last version of the .cia file?
     
  22. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
  23. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    Is this related to there being two separate titles for the old and new 3DS versions of abgbg? At least that's what I've read.
     
  24. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    It's not related to old3DS or new3DS. This is related to a specific Title version, and the success of the patches depends on how the compiler was feeling the day AgbBg was compiled. I need a pair of instructions to be 4-aligned, otherwise I can't run my own code. This is why there is a 50% chance of the patches not working at all.
     
  25. piratesephiroth

    piratesephiroth I wish I could read

    Member
    11
    Sep 5, 2013
    Brazil
    Isn't it enough that the 3DS has been updated at least once in the last 5 years or so?
    The firms are the same for all regions so only their versions should be different, and you can't have outdated versions unless you really intend to do that.
     
  26. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    Dunno. None of the FIRMs I have seems to be affected, so I think that the section of code I'm intercepting might be always 4-aligned on all version of AgbBg. I just mentioned it just in case there is an obscure version installed on some Korean or Taiwanese 3DS which doesn't happen to work.
     
  27. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    Sounds like it might be sliiightly lower than 50% chance then. :P
     
  28. Sophie-bear

    Sophie-bear The Coolest Bear Around

    Member
    7
    Jan 4, 2017
    United States
    I think the "50% chance" is in reference to the binary possibility of having vs not having the working firm, lol. You either do or don't, after all.
     
    Sono likes this.
  29. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    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.
     
Quick Reply
Draft saved Draft deleted
Loading...