Homebrew TWPatcher - DS(i) mode screen filters and patches

  • Thread starter Sono
  • Start date
  • Views 745,588
  • Replies 2,428
  • Likes 101

Are you interested in a complete replacement of TwlBg which includes all patches?

  • Yes, I don't care how broken it will be!

    Votes: 188 79.3%
  • No, I don't want to use even more broken stuff

    Votes: 20 8.4%
  • Yes, but only in GBA mode, because I play DSi exclusives

    Votes: 12 5.1%
  • No, because I only use DS and DSi mode

    Votes: 17 7.2%

  • Total voters
    237
  • Poll closed .

PokeNev

Well-Known Member
Member
Joined
Nov 11, 2018
Messages
336
Trophies
0
Age
26
XP
960
Country
United States
Redo all the widescreen steps exactly.
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

Redo all the widescreen steps exactly.
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,
  • Like
Reactions: DSoryu

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,260
Country
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
 

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,260
Country
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.
 

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,260
Country
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!
 

evertonstz

Well-Known Member
Member
Joined
Jan 5, 2019
Messages
209
Trophies
0
Age
29
XP
557
Country
Brazil
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!

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,
  • Like
Reactions: leonmuse

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,260
Country
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,
  • Like
Reactions: evertonstz

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,820
Trophies
2
Location
home
XP
9,309
Country
Hungary
It's already good weather here, I feel much better, but I still can't work on TWPatch yet, because I'm still setting up the new Linux install after wiping lose10 (windoze 10, but you don't win anything, so it's lose10) , so it'll still take a few days.
I can compile 3DS homebrew just fine in wine, so I can keep my old setup, which makes me waste less time. The only thing I'm really missing is just the code editor. I think there is VSCode for Linux, so it should take a few days max until I can setup everything, assuming I don't run into more wine-related bugs.

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.
 

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,260
Country
United States
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.

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.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,820
Trophies
2
Location
home
XP
9,309
Country
Hungary
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.

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.
 

piratesephiroth

I wish I could read
Member
Joined
Sep 5, 2013
Messages
3,453
Trophies
2
Age
103
XP
3,232
Country
Brazil
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.
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.
 

Sono

cripple piss
OP
Developer
Joined
Oct 16, 2015
Messages
2,820
Trophies
2
Location
home
XP
9,309
Country
Hungary
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.

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.
 

Rahkeesh

Well-Known Member
Member
Joined
Apr 3, 2018
Messages
2,178
Trophies
1
Age
42
XP
3,260
Country
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.

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.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: Hello @realtimesave.