TWPatcher - DS(i) mode screen filters and patches

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

  1. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    The only problem with manual patching is that I have a TwlBg either from a pre-1.0.0 factory dump, or a 11.0 dump (I forgot which one), and according to Robz8 's post eariler the offset can be off. But I'll try my best to help the user to locate it.

    I added the patch into the first post.
     
    Dartz150, Robz8 and SomeGamer like this.
  2. Dartz150

    Dartz150 Hat Gurl Official Fan™

    Member
    10
    May 5, 2010
    Mexico
    Under your bed
    @Robz8 Would it be possible to implement said patcher in the Twilight++ updater in the extras section? It would be very convenient :D. For me, I'll be testing your patch manually @Sono when I get home, is it possible to share the offsets and the values to be changed? Or it cannot be shared for the CR reasons? Thank you very much for your findings, finally we will play NDS games visually better than before.

    EDIT: Ninja'd, thanks for the patch info.
     
    Last edited by Dartz150, Jul 5, 2019
  3. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    It's definitely possible. I'll look into it.

    Oh, I left the patch notes in the first post. That's the best I have for now.
     
    Robz8 and Dartz150 like this.
  4. Dartz150

    Dartz150 Hat Gurl Official Fan™

    Member
    10
    May 5, 2010
    Mexico
    Under your bed
    I see, great! And yeah, I just saw your notes, I wasn't aware before haha. Sorry for the bothering and thank you very much for your work.
     
    Sono likes this.
  5. Ryccardo

    Ryccardo and his tropane alkaloids

    Member
    14
    Feb 13, 2015
    Italy
    Imola
    Not working on 11.10 N3DS - 4A7F4 is right in the middle of a block of strings, and there's no "004EFCA5" anywhere in TwlBG's executable (compressed or not)...
     
  6. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    It's not in the middle of strings, but there are some strings around it. You don't search for "4A7F4" or "4EFCA5", you go to (CTRL-G in HxD) the address 0x4A7F4, and check if the bytes around the cursor are 00 00 00 00 00 00 00 40 00 00 00 00
    Once you find that pattern, you select the pattern, and go to the end of the last zero, and then you overwrite the bytes there with
    000000000000000000000000000000000000000000000000000000000020004000400040004000200000000000000000000000000000000000000000
     
  7. Ryccardo

    Ryccardo and his tropane alkaloids

    Member
    14
    Feb 13, 2015
    Italy
    Imola
    Yeah, I knew 4A7F4 is supposed to be the address, but...
    C1apture.PNG C2apture.PNG
     
  8. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    Oh no, they updated the binary :(

    Also, how did you manage to get code.bin but compressed? If you followed my tutorial then code.bin should always be decompressed :unsure:

    But anyway, try to find
    00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 00 00 00 00 00 00 00 00 00
    instead, and count 60 (as in, 0x3C) bytes backwards from the start of this pattern. There should be only a single find for this pattern.
     
    Ryccardo likes this.
  9. Ryccardo

    Ryccardo and his tropane alkaloids

    Member
    14
    Feb 13, 2015
    Italy
    Imola
    Actually, when you refer to ihaveamac's github, it says in point 3 of the 3dstool variant how to extract cxi > exefs.bin > exefs/code.bin (compressed) and then in step 4 to extract exefs/code.bin in ./decompressed-code.bin, but then going back to your instructions you say to open exefs/code.bin :)

    Not knowing if it was already uncompressed inside the cxi (and too lazy to check the exheader) I simply tried both :D

    Found that sequence at 40BD0, indeed it's the only copy of it... changed the block just before... and it's working (at least as in not crashing DS mode) :)
     
    Sono likes this.
  10. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    I'd actually be interested in applying a smoother scaling algorithm to GBA games, maybe even trying the DS one. Hopefully a similar process would work on AGB_FIRM.
     
  11. Dartz150

    Dartz150 Hat Gurl Official Fan™

    Member
    10
    May 5, 2010
    Mexico
    Under your bed
    2019-07-05_20-14-15.

    Just to confirm, I found the code pattern at 4B090 as well, the size is 0x3C. I'm at System version 11.10.0-43U if that info helps Sono . I'm about to recompile the patched xci and I'll edit this post with my result.

    EDIT: I get this error when trying to repack exfs.bin

    Code:
    ERROR: open file exefsheader.bin failed
    ERROR: create file failed
    Presione una tecla para continuar . . .
    
    Strangely, exefsheader.bin does not exist in the directory where I unpacked the cxi in the previous step, did I miss something?

    EDIT 2: I had to manually extract the headers and make the header files as 3dstool always failed, it's pretty easy so not a problem.

    Finally got the patch output file, it seems that your code disables the blurry filtering and leaves the image upscaled in some type of "raw" looking way, like when you disable bilinear filtering in retroarch or various emulators. It may be not perfect but definitely is much much better than the default scaling method:



    Again, thank you very much for your tutorial @Sono , looking forward to more findings and filtering methods if available! :D
     
    Last edited by Dartz150, Jul 6, 2019
  12. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    Sadly AGB_FIRM is already as crisp as it can be, however it's possible to do a full-on linear interpolation by searching for the pattern
    00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 00 00 00 00 00 00 00 00 00
    and replacing it with
    00000000000000000000000000000000000000000000000000005615AA2A00000000AA2A0040AA2A56150040561556150000000000000000AA2A0000000000000000000000000000

    I didn't test this, but hopefully this shouldn't hardlock the matrix unit, and should have an even linear interpolation.
     
    Dartz150 likes this.
  13. botik

    botik Member

    Newcomer
    4
    Sep 22, 2017
    Russia
    I find in decompress code.bin 11.10
     

    Attached Files:

    Dartz150 and Sono like this.
  14. monkeyman4412

    monkeyman4412 Gbatemp's moronic trash

    Member
    8
    Jun 16, 2016
    United States
    Darn, I can't come up with something edgy
    Weird... I'm not finding it at all, even with what people said and addresses... Who is using what version of a 3ds/2ds (new or old) and what firmware.
     
  15. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    You have to search in the decompressed code. I'm using either the 11.0 TWL_FIRM, or a pre-1.0.0 TWL_FIRM, I don't know which one.
     
  16. monkeyman4412

    monkeyman4412 Gbatemp's moronic trash

    Member
    8
    Jun 16, 2016
    United States
    Darn, I can't come up with something edgy
    I'm using decompressed rn, not finding it all. Twl firm is different between old and new 3ds's if I recall correctly. I use a new system, specifically n2ds

    — Posts automatically merged - Please don't double post! —

    never mind finally found it
     
  17. ahezard

    ahezard GBAtemp Regular

    Member
    6
    Feb 17, 2016
    France
    This is super nice! congratulations! When I was researching twl_firm I made some scripts to automatically patch it : https://github.com/ahezard/twl_firm_patcher
    I can adapt it to includes your patches in it. Still the best would be to have these patches included in the cfw (Luma, etc).
     
    Kvnrdrguez, zfreeman, Robz8 and 3 others like this.
  18. Sono
    OP

    Sono Modern slave

    Member
    13
    Oct 16, 2015
    Hungary
    Austro-Hungarian Monarchy
    Sure. I'll make a few presets then, so people with different tastes can replace that awful blur filter Nintendo is using with a much higher quality blur filter.

    It'll take a few days most likely though, because I don't have too much time.
     
    Feffe, KyleHyde, zfreeman and 6 others like this.
  19. Alex658

    Alex658 GBAtemp Maniac

    Member
    5
    Jun 4, 2010
    Venezuela
    Venezuela
    This is amazing. Great work!

    One question, if we are loading TWL_FIRM externally from Luma, does this mean our original one remains safe and unpatched within the hardware firmware? Since i'm an end user i'll wait until the process is automated as to not screw it up. But this is amazing work nonetheless!!
     
  20. Dartz150

    Dartz150 Hat Gurl Official Fan™

    Member
    10
    May 5, 2010
    Mexico
    Under your bed
    Yes, your TWL_FIRM in the NAND stays untouched, if you want to revert back you only need to disable module patching or simply delete the patch.
     
    Catiorro, plug313 and Sono like this.
Quick Reply
Draft saved Draft deleted
Loading...