?

What should be the fate of the cia patcher?

Poll closed Saturday at 2:58 AM.
  1. Just finish it already!

    41.7%
  2. Keep redshift and rtcom only, rest goes to DS side

    8.3%
  3. Just make the exe patcher work on the 3DS, the rest is fine DS-side

    50.0%
  1. selcuk

    selcuk Member
    Newcomer

    Joined:
    Oct 3, 2015
    Messages:
    39
    Country:
    any solution?
     
  2. selcuk
    This message by selcuk has been removed from public view by Flame, Dec 14, 2019, Reason: asking for copyright material..
    Dec 14, 2019 Show
  3. selcuk

    selcuk Member
    Newcomer

    Joined:
    Oct 3, 2015
    Messages:
    39
    Country:
    btw @Sono I have done a ctrtransfer in the past so maybe that's why it doesn't work.?
     
  4. selcuk

    selcuk Member
    Newcomer

    Joined:
    Oct 3, 2015
    Messages:
    39
    Country:
    damn @Sono got it wrking finally I renamed section0.bin to agbg0.bin and the percentage of bytes used were 91 so it should be fine
     
    Sono likes this.
  5. TR_mahmutpek

    TR_mahmutpek medic
    Member

    Joined:
    Jul 28, 2015
    Messages:
    1,258
    Country:
    Turkey
    @Sono Thx man. Keep it up the work! You developers make the scene great and live!
     
    Sono likes this.
  6. Sono

    OP Sono Modern slave
    Member

    Joined:
    Oct 16, 2015
    Messages:
    1,934
    Country:
    Hungary
    I just checked the patcher's source, and I'm really sorry, but I forgot I change the filename so I don't need to keep backing up and renaming the file each time I want to work with TwlBg or AgbBg.

    Yeah, you need to name it agbg0.bin instead of section0.bin, my apologies.
     
  7. selcuk

    selcuk Member
    Newcomer

    Joined:
    Oct 3, 2015
    Messages:
    39
    Country:
    It seems I can't find
    Code:
     0000 0020 0040 0000 0020 0040 0040 0020 0000 0040 0020 0000
    in HxD... can you help?
     
  8. Rahkeesh

    Rahkeesh GBAtemp Maniac
    Member

    Joined:
    Apr 3, 2018
    Messages:
    1,292
    Country:
    United States
    Either you are doing a search in decimal mode (default) instead of hex, or you might have the wrong .cxi file.

    Depending on how you got the .cxi file, it may need to be unpacked/decrypted, and will need repacking/encrypting before use. You won't be able to find that string in an encrypted file.
     
    Last edited: Dec 16, 2019
  9. selcuk

    selcuk Member
    Newcomer

    Joined:
    Oct 3, 2015
    Messages:
    39
    Country:
    How do I know if its rncrypted or not.?
    I got the file from the patcher. AgbBg.cxi
     
  10. Rahkeesh

    Rahkeesh GBAtemp Maniac
    Member

    Joined:
    Apr 3, 2018
    Messages:
    1,292
    Country:
    United States
    So you can't directly hex edit the cxi file, at least I don't think so. I actually edit code.bin which gets put in the exefs folder after unpacking the contents of agbbg.cxi with ctrtool or 3DStool, can't remember which. I wrote a bat file to pack the results of editing into the .cxi file, maybe you can figure out the rest from taking a look at that and finding the tutorial that you probably need to follow to even get agbbg.xci out in the first place. (its basically the same process as has been laid out in this thread for twlbg.xci, you just need to pick the title for GBA instead when extracting with GM9)

    Code:
    3dstool -czvtf exefs exefs.bin --exefs-dir exefs --header exefsheader.bin
    3dstool -cvtf cxi AgbBg.cxi --header ncchheader.bin --exh exheader.bin --exefs exefs.bin --not-encrypt
    
     
  11. selcuk

    selcuk Member
    Newcomer

    Joined:
    Oct 3, 2015
    Messages:
    39
    Country:
    I made agbbg.cxi correctly and unpacked it using 3dstool and firm tool. But I still can't find the hex code.
     
  12. Rahkeesh

    Rahkeesh GBAtemp Maniac
    Member

    Joined:
    Apr 3, 2018
    Messages:
    1,292
    Country:
    United States
    If it helps, I found that hex string around address 4A1B0 in code.bin. I understand these addresses can differ. Mine came from fairly recent firmware (1.13?)

    If you're using an agbbg.xci edited by Sono's command line patcher then I doubt any of my suggested edits will work. I extracted this stuff straight from my 3DS NAND via GM9.
     
    Last edited: Dec 19, 2019
    selcuk likes this.
  13. Rahkeesh

    Rahkeesh GBAtemp Maniac
    Member

    Joined:
    Apr 3, 2018
    Messages:
    1,292
    Country:
    United States
    So I'm revisiting agbbg.cxi and trying to work on sharpening. It seems like you can't go past F100 for negative numbers, I always get black screen/no sound if I do, which limits how much you can sharpen. I'm assuming negative numbers in the matrix work like typical integers, i.e. two's complement encoding so FFFF = 1, 8000 = -32,768, etc, and of course is encoded in little endian (so really 00F1, etc). Wondering if there is any theory to explain this limitation or any workaround past it.
     
  14. Mikitok

    Mikitok GBAtemp Regular
    Member

    Joined:
    Jan 14, 2019
    Messages:
    181
    Country:
    New Zealand
    Noob question this work with flashcarts?
     
  15. Robz8

    Robz8 Coolest of TWL
    Developer

    Joined:
    Oct 1, 2010
    Messages:
    11,828
    Country:
    United States
    The filters work throughout DS/DSi mode, so yes.
     
    Mikitok likes this.
  16. Rahkeesh

    Rahkeesh GBAtemp Maniac
    Member

    Joined:
    Apr 3, 2018
    Messages:
    1,292
    Country:
    United States
    Here's a Christmas "gift": an excel / google sheet that calculates AGB matrices, to be copied into a hex editor editing code.bin extracted from agbbg.cxi. It allows you to fine tune increases to smoothing and sharpening, yielding results closer to how DS scaling is done by default on 3DS, although with much better results as 2->3 is an easier scale than 4->5. It has two values to be edited in the upper left, taking a decimal between 0 and 1 inclusive, with 0s entered in to match the default state of unmodified agbbg.cxi.

    First ensure you know where the matrix code is in your code.bin. Because the sheet starts off with the default values (from 0 in both linear smoothing and edge sharpening), you can copy the lower line that has all the hex codes and search for that with an editor like HxD. On mine it starts at address 4A1A8 and goes to 4A1D7. Go ahead and select this space because that is what we will be replacing.

    The first factor is "linear smoothing." The default of 0 makes it semi-"crisp" and pixelly, but can also distort shapes, like the outlines of the comic cutscenes in Zero Mission. This is because pixels from the original image are not factored into the scaled one equally. A value of 1 eliminates pixelness and perfectly weights all pixels in the final image, but makes things extremely smooth/blurred.

    To combat added blur by turning up linear smoothing, you can use the edge sharpening factor. This is a simple sharpening algorithm as you might see on TVs or monitors, it tends to enhance strong contrasts of neighboring colors, but can produce unwanted ringing/halo artifacts. 0 is no sharpening, while a value of 1 is the max sharpening allowed. (which isn't *that* sharp, so don't be afraid to try it.)

    Once you've set your values, copy the code line at the bottom to the appropriate place in code.bin we highlighted earlier. Then save and rebuild agbbg.xci as normal and drop in luma/sysmodules on your SD card. I kind of like smoothing .5 and sharpening .7 but feel free to try other values.

    If you've played with these hex edits before, give my excel file a try. You can also read some boring technical details below.

    As to why I've been working on this: the default AGB scaling does not treat every pixel evenly. The basic job that has to be done is to turn 4 GBA pixels into 9 on the 3DS. As far as I can tell, the original matrix accomplishes this by creating little cubes of 4 original pixels and fills out the edge with 5 interpolated ones that evenly blend the nearest pixels. While somewhat sharp this distorts the original shapes because in the scaled image there is zero space between some original pixels while others have an interpolated pixel placed between them. Spacing every pixel evenly actually means not directly copying any source pixels though, instead its always a blend of like 75% one and 25% another at best, which means to represent shapes and space accurately you are left with blur at a 2->3 upscale. However we can use traditional sharpening to help combat this, and with some compromise we something we can get something that is more accurate and still sharp or sharp enough.

    Because I can't figure out how to go over -F00 in any one pixel, a factor of "1" gives you the maximum possible sharpening while keeping everything proportional. I find 1 is already borderline on making annoying artifacts so it isn't too much a loss that you can't push further. Note that the overall strength of sharpening increases slightly as linear smoothing increases, because while the maximum pixel value is fixed at F00 the minimum values will be higher to remain in proportion with the smoother minimum (x10 instead of x0)

    Google Sheets link
     

    Attached Files:

    Last edited: Dec 26, 2019
    Zense, iGom, Sono and 3 others like this.
  17. Sono

    OP Sono Modern slave
    Member

    Joined:
    Oct 16, 2015
    Messages:
    1,934
    Country:
    Hungary
    Can you please take a screenshot of it? I can't try this because I don't have Excel, but I'm also interested in how it looks like.
     
    Robz8 and Dodain47 like this.
  18. Rahkeesh

    Rahkeesh GBAtemp Maniac
    Member

    Joined:
    Apr 3, 2018
    Messages:
    1,292
    Country:
    United States
    Its using a bunch of formulas so a screenshot is not that helpful. I thought openoffice could open this for free on basically any machine? I can try to lay out the formulas here otherwise, there aren't that many, but its probably easier to play with it if you can.

    Edit: here's a shot anyway

    agb calc.png

    Edit2: I can probably make a google document version, that would be more accessible

    Edit3: here's a viewable google sheets link, hopefully you can make a copy into your own drive for editing, let me know if not.

    Google Sheets
     
    Last edited: Dec 26, 2019
    Sono likes this.
  19. Sono

    OP Sono Modern slave
    Member

    Joined:
    Oct 16, 2015
    Messages:
    1,934
    Country:
    Hungary
    Hmm... it's an interesting concept :unsure: But it seems to be invalid, because you're only printing 6 * 4 values, when you need 6 * 6 values for GBA upscaling, and 6 * 5 values for bottom-screen-fitting DS scaling. 6 * 4 values can be used for the 1x "upscaling", but why would anyone apply a filter to a pixel-perfect image?
     
  20. Rahkeesh

    Rahkeesh GBAtemp Maniac
    Member

    Joined:
    Apr 3, 2018
    Messages:
    1,292
    Country:
    United States
    When I tried filling the furthest areas to treat it like 6x (4A19C-4A1A7 for example) I got crashes. Maybe there's some valid values to put there but I didn't play with it further for now. So according to your account this is generating an incomplete matrix but it works fine when pasted over the default in the right position (i.e. the center), with these leftmost and rightmost slots occupied by the default 0s. I don't need those slots for the current simple formula but it could open up more effects to play with.
     
    Last edited: Dec 27, 2019
  21. Sono

    OP Sono Modern slave
    Member

    Joined:
    Oct 16, 2015
    Messages:
    1,934
    Country:
    Hungary
    I never had luck with HxD either, hence I made the patcher.

    Also, I didn't realize you're not replacing the entire matrix, sorry for that. But sadly for most scaling you have to replace the entire matrix :/

    Now that you reminded me, I promised a scale matrix editor for when I'll figure out how to use matrixes. I guess it's time for me to do it? :wacko:

    Edit: This is turning out much easier and better than I expected... screw Javascript libraries, VanillaJS is the shit!
    [​IMG]
     
    Last edited: Dec 27, 2019
    seseiSeki and Rahkeesh like this.
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - TWPatcher, filters, patches