Hacking Changing the internal resolution of the Virtual Console DS Emulator

Lorenz_

New Member
OP
Newbie
Joined
Nov 1, 2024
Messages
4
Trophies
0
Age
24
XP
56
Country
United States
Hello everyone.

For the games it supports, the Virtual Console DS emulator is, in my opinion, the best way to play DS games. The Wii U gamepad is a perfect way to handle the second screen, something PC DS emulators struggle with. There is one aspect with which PC emulators are universally better though, and that is with upscaling. For the uninitiated, upscaling is process of taking an image and increasing its resolution so that it can be displayed at a larger size. The way the DS Virtual Console emulator handles upscaling from the tiny DS screen to the relavitly massive Wii U screen is less than graceful.

There is a "Screen Settings" option within the emulator that lets you set the size and location of each display to a number of preset options. Your options are pretty limited, but fortunately, you can set the size and location to whatever you'd like by editing a file called "configuration_cafe.json" in the "content\0010" folder of the emulator's files.

Both displays on the DS have a resolution of 256 x 192, so setting the size of a screen to a multiple of said resolution (i.e. 256 x 192, 512 x 384, 768 x 576, ect.) will use integer scaling while upscaling the image. Integer scaling means that every pixel of the DS' display corresponds to a perfectly square array of pixels on the Wii U's display. This produces a very sharp looking image, and it is by far the best way to upscale displays as low resolution as the DS' screens. The trade-off to using integer scaling is that it requires the DS screen size to be set to a small number of fixed values, so invariably you will need letterboxing (black bars to fill the sides of the screen) to make up for the fact that none of the fixed sizes fill up the Wii U's entire display.

If the size is not set to a multiple of 256 x 192, the screens will still upscale, but they will use a more sophisticated upscaling algorithm that leaves artifacts. Under most circumstances, these artifacts aren't too noticable, and they are worth the trade-off of being able to set the DS screen size to something that fills most of the Wii U's displaty with little letterboxing. This is not the case with vertically oriented games. The below screenshot is the default layout for vertically oriented DS games. It scales each screen to 522 x 696 (696 x 522 rotated 90°). The game pictured is Tokimeki Memorial: Girl's Side - 1st Love Plus.
720p_Scaling_0.png

When upscaled to this resolution, illistrations (characters, backgrounds, ect.) look fine, but the font is abrasively terrible. Notice how the strokes of letters are of unequal thickness. The stem of the letters like "t," "k," and "p" are sometimes way too thin. The letters like "w" and "o" loose their symmetry. The curvature on almost every letter looks squished. The more you look at it, the worse it gets. It would be an exageration to say it makes the game unplayable, but it is distracting to the point that it is massivly determintal to the experience.

You are able to switch to a different upscaling algorithm by changing the "PixelArtUpscaler" setting in configuration_cafe.json from 0 to 1, but I think the results speak for themselves:
720p_Scaling_1.png


The natural solution to this problem would be to adjust the size of the DS screens so that they use integer scaling. The internal resolution of the Virtual Console DS emulator is 1280 x 720, so the largest possible multiple of 192 x 256 you can set the DS screen size to without exceeding the bounds of the display is 384 x 512. That looks like this:
720p_Integer_Scaling.png

The image becomes very sharp. In my opinion, this is much more acceptable than the above two, but there is a new problem in that the letterboxing is rather egregious. Fortunately, there is (potentially) a solution.

The limiting factor in increasing the size further is the height of the DS display, so the following calculations will focus on the y-axis of the resolution. The perctange of the y-axis that consists of letter boxing when using the largest possible integer scaling compatible screen size can be calcualted with the equation "100 * (n mod 256) / n" where n is the height of the emulator's internal resolution. The Wii U has three possible wide screen resolutions: 1920 x 1080, 1280 x 720, and 856 x 480. Here is what the percantage of vertical lettboxing is for each:

480p: 100 * (480 mod 256) / 480 = 46.67% of the height is letterboxing.
720p: 100 * (720 mod 256) / 720 = 28.89% of the height is letterboxing.
1080p: 100 * (1080 mod 256) / 1080 = 5.19% of the height is letterboxing.

For whatever reason, even though the Wii U's maximum output resolution is 1920 x 1080, the developers of the Virtual Console DS emulator set the app's internal resolution to 1280 x 720. Had they instead opted to set the emulator's resolution to 1080p, it would be possible to use integer scaling with virtually no letterboxing. I made a mockup of what that would look like:
1080p_MOCKUP.png

This image is immaculate. My goal is to try to modify the Virtual Console DS emulator's executable file to increase its internal resolution from 1280 x 720 to 1920 x 1080 to allow for scaling like in the mockup above. With a little research, I was able to convert the emulator's .rpx file to a .elf file, open it in Ghidra, edit it, and re-convert it back to a .rpx file that runs both in CEMU and on original hardware. Here is where I hit a wall; I am not at all familiar with the Wii U's rendering framework, and documentation of it online is scarce. I don't really know what to do from here.

I tried searching for instances of the constants 1280 and 720 and changing them to 1920 and 1080 respectively. Going off of another thread I found on GBATemp, I tried changing the value of the third parameter of GX2SetTVBuffer() from 2 to 4. I may have made a few other changes, but to be perfectly honest, this was a few days ago and I don't remember perfectly.

After a lot of trial and error, I got the emulator to boot at a higher resolution... kinda....
1080p_MODIFIED_A.png

The app's resolution increased, but the DS screens where still drawn to the bounds of 1280 x 720. If I try to open the Virtual Console menu, it looks like this:
1080p_MODIFIED_B.png

This screen also appears bounded to 720p, only its centered. Interestingly, you can actually see the buttons fly in from the "out of bounds" region of the screen during the animation that plays upon opening the menu. Ultimately, I don't mind this screen being wrong. The biggest problem my changes cause is that they make the emulator incredibly unstable. The emulator hangs on boot if you have restore point data, and most games can't get past the title screen before a crash. Brain Age (which is the e-shop release this instance of the emulator is from, if that matters) can't even boot to the title screen. It crashes after the intro screen.

I have a suspicion that these problems are solvable, but I don't have enough technical knowledge about the Wii U to know how to proceed from here. If anyone has any ideas, please let me know. If it would help, I can generate an xdelta patch for my new version of the emulator's rpx file. I can also go back and try to see the exact changes I made in Ghidra.

Thank you,
Lorzen
 

Attachments

  • 1080p_MODIFIED_A.png
    1080p_MODIFIED_A.png
    56.9 KB · Views: 9
  • 1080p_MODIFIED_B.png
    1080p_MODIFIED_B.png
    234.2 KB · Views: 7

Ettino

Well-Known Member
Member
Joined
Oct 12, 2022
Messages
695
Trophies
0
XP
1,418
Country
Canada
The Wii U gamepad is a perfect way to handle the second screen, something PC DS emulators struggle with.
Struggle? I just turn one of my monitor vertically and bam both DS screens on 1 monitor. These days though, any half way decent phone or tablet can run DS emulator better than the Wii U. No issue with DSi games either.
 

sonictopfan

Well-Known Member
Member
Joined
Mar 2, 2010
Messages
2,800
Trophies
1
XP
2,243
Country
Quite interesting, meanwhile I'm still waiting for a response for my question few years ago regarding the mic support on the DS VC emulator, the games I injected don't seem to register the mic, some are required to progress, then we have Brain Age that has mic support.
 

Unithrex

Member
Newcomer
Joined
Jul 3, 2023
Messages
15
Trophies
0
Age
21
XP
69
Country
United States
Hello everyone.

For the games it supports, the Virtual Console DS emulator is, in my opinion, the best way to play DS games. The Wii U gamepad is a perfect way to handle the second screen, something PC DS emulators struggle with. There is one aspect with which PC emulators are universally better though, and that is with upscaling. For the uninitiated, upscaling is process of taking an image and increasing its resolution so that it can be displayed at a larger size. The way the DS Virtual Console emulator handles upscaling from the tiny DS screen to the relavitly massive Wii U screen is less than graceful.

There is a "Screen Settings" option within the emulator that lets you set the size and location of each display to a number of preset options. Your options are pretty limited, but fortunately, you can set the size and location to whatever you'd like by editing a file called "configuration_cafe.json" in the "content\0010" folder of the emulator's files.

Both displays on the DS have a resolution of 256 x 192, so setting the size of a screen to a multiple of said resolution (i.e. 256 x 192, 512 x 384, 768 x 576, ect.) will use integer scaling while upscaling the image. Integer scaling means that every pixel of the DS' display corresponds to a perfectly square array of pixels on the Wii U's display. This produces a very sharp looking image, and it is by far the best way to upscale displays as low resolution as the DS' screens. The trade-off to using integer scaling is that it requires the DS screen size to be set to a small number of fixed values, so invariably you will need letterboxing (black bars to fill the sides of the screen) to make up for the fact that none of the fixed sizes fill up the Wii U's entire display.

If the size is not set to a multiple of 256 x 192, the screens will still upscale, but they will use a more sophisticated upscaling algorithm that leaves artifacts. Under most circumstances, these artifacts aren't too noticable, and they are worth the trade-off of being able to set the DS screen size to something that fills most of the Wii U's displaty with little letterboxing. This is not the case with vertically oriented games. The below screenshot is the default layout for vertically oriented DS games. It scales each screen to 522 x 696 (696 x 522 rotated 90°). The game pictured is Tokimeki Memorial: Girl's Side - 1st Love Plus.
View attachment 468908
When upscaled to this resolution, illistrations (characters, backgrounds, ect.) look fine, but the font is abrasively terrible. Notice how the strokes of letters are of unequal thickness. The stem of the letters like "t," "k," and "p" are sometimes way too thin. The letters like "w" and "o" loose their symmetry. The curvature on almost every letter looks squished. The more you look at it, the worse it gets. It would be an exageration to say it makes the game unplayable, but it is distracting to the point that it is massivly determintal to the experience.

You are able to switch to a different upscaling algorithm by changing the "PixelArtUpscaler" setting in configuration_cafe.json from 0 to 1, but I think the results speak for themselves:
View attachment 468918

The natural solution to this problem would be to adjust the size of the DS screens so that they use integer scaling. The internal resolution of the Virtual Console DS emulator is 1280 x 720, so the largest possible multiple of 192 x 256 you can set the DS screen size to without exceeding the bounds of the display is 384 x 512. That looks like this:
View attachment 468926
The image becomes very sharp. In my opinion, this is much more acceptable than the above two, but there is a new problem in that the letterboxing is rather egregious. Fortunately, there is (potentially) a solution.

The limiting factor in increasing the size further is the height of the DS display, so the following calculations will focus on the y-axis of the resolution. The perctange of the y-axis that consists of letter boxing when using the largest possible integer scaling compatible screen size can be calcualted with the equation "100 * (n mod 256) / n" where n is the height of the emulator's internal resolution. The Wii U has three possible wide screen resolutions: 1920 x 1080, 1280 x 720, and 856 x 480. Here is what the percantage of vertical lettboxing is for each:

480p: 100 * (480 mod 256) / 480 = 46.67% of the height is letterboxing.
720p: 100 * (720 mod 256) / 720 = 28.89% of the height is letterboxing.
1080p: 100 * (1080 mod 256) / 1080 = 5.19% of the height is letterboxing.

For whatever reason, even though the Wii U's maximum output resolution is 1920 x 1080, the developers of the Virtual Console DS emulator set the app's internal resolution to 1280 x 720. Had they instead opted to set the emulator's resolution to 1080p, it would be possible to use integer scaling with virtually no letterboxing. I made a mockup of what that would look like:
View attachment 468932
This image is immaculate. My goal is to try to modify the Virtual Console DS emulator's executable file to increase its internal resolution from 1280 x 720 to 1920 x 1080 to allow for scaling like in the mockup above. With a little research, I was able to convert the emulator's .rpx file to a .elf file, open it in Ghidra, edit it, and re-convert it back to a .rpx file that runs both in CEMU and on original hardware. Here is where I hit a wall; I am not at all familiar with the Wii U's rendering framework, and documentation of it online is scarce. I don't really know what to do from here.

I tried searching for instances of the constants 1280 and 720 and changing them to 1920 and 1080 respectively. Going off of another thread I found on GBATemp, I tried changing the value of the third parameter of GX2SetTVBuffer() from 2 to 4. I may have made a few other changes, but to be perfectly honest, this was a few days ago and I don't remember perfectly.

After a lot of trial and error, I got the emulator to boot at a higher resolution... kinda....
View attachment 468961
The app's resolution increased, but the DS screens where still drawn to the bounds of 1280 x 720. If I try to open the Virtual Console menu, it looks like this:
View attachment 468963
This screen also appears bounded to 720p, only its centered. Interestingly, you can actually see the buttons fly in from the "out of bounds" region of the screen during the animation that plays upon opening the menu. Ultimately, I don't mind this screen being wrong. The biggest problem my changes cause is that they make the emulator incredibly unstable. The emulator hangs on boot if you have restore point data, and most games can't get past the title screen before a crash. Brain Age (which is the e-shop release this instance of the emulator is from, if that matters) can't even boot to the title screen. It crashes after the intro screen.

I have a suspicion that these problems are solvable, but I don't have enough technical knowledge about the Wii U to know how to proceed from here. If anyone has any ideas, please let me know. If it would help, I can generate an xdelta patch for my new version of the emulator's rpx file. I can also go back and try to see the exact changes I made in Ghidra.

Thank you,
Lorzen
There is a way to change the resolution of the window to get widescreen in n64 vc https ://gbatemp.net/threads/wiiu-virtual-console-finally-fixed-no-more-dark-filter-and-widescreen-support.517158/. I'd recommend trying that with ds vc
 

Lorenz_

New Member
OP
Newbie
Joined
Nov 1, 2024
Messages
4
Trophies
0
Age
24
XP
56
Country
United States
There is a way to change the resolution of the window to get widescreen in n64 vc . I'd recommend trying that with ds vc
No luck. The DS emulator doesn't have any .arc files. The functional equivalent to the N64 emulator's .arc files, the "configuration_cafe.json" file, allows you to change the brightness and DS display resolution within the emulator application, but it does not allow you to change the emulator application's internal resolution.
 
  • Like
Reactions: Unithrex

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • SylverReZ @ SylverReZ:
    My theory is that once he said he owns hacked Switches and sells them to friends, probably discussed about it on the same subreddit that Nintendo sued a bunch of modders on. Or, the second, being that he decided to log off and move on with his life. Maybe one day he'll come back to GBAtemp.
  • BigOnYa @ BigOnYa:
    Or 3, he's moved into an apartment across the street from you, watching and waiting for the right time to pounce.
    +1
  • K3Nv2 @ K3Nv2:
    If you see nice things being moved in and massive pallets of old hard drives run
    +2
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    @SylverReZ, life is just DUCKY!!!
    +1
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    @K3Nv2, how's life for you?
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    @K3Nv2, CHRIST, everybody is gone again!!! Maybe it's me, I only shower once a year... :(
  • SylverReZ @ SylverReZ:
    @The_Dizzy_Vizzy, Everybody might be busy with other things, you just got to be patient.
  • SylverReZ @ SylverReZ:
    I'm around if you want to chat. :)
  • SylverReZ @ SylverReZ:
    Don't expect an instant reply, though.
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    It's all good chief, I'm going to watch the film TROY, with Brad Pitt, and on the 6th (this Friday) we are going to see "The Return", when Ulysses returns and kills EVRYBODY.
    +1
  • K3Nv2 @ K3Nv2:
    Like how it takes them ten minutes to find trumps shooter but can't find a guy that blows off the ceo of united health care
    +2
  • SylverReZ @ SylverReZ:
    @K3Nv2, The fuck?
  • K3Nv2 @ K3Nv2:
    Someone blowing off the ceo of a health insurance company?
  • SylverReZ @ SylverReZ:
    @The_Dizzy_Vizzy, Sounds like fun. Hope you guys enjoy the movie, let me know how it went afterwards.
    +1
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    @SylverReZ, You like Brad Pitt? I've been saying for YEARS that this cat is going to get an Academy Award". Not that I care for that kind of shit, but he's a great actor. He finally got one for best supporting actor in "Once Upon A Time......In Hollywood". Great film. If you haven't seen it, by all means watch it. It's the story of Sharon Tate, who was SLAUGHTERD by the Manson family.
  • SylverReZ @ SylverReZ:
    @The_Dizzy_Vizzy, I've heard of Brat Pitt, he played one of the people in Fight Club.
    +1
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    @SylverReZ, but the movie is a re-imagining of how this went, she lives. Great flick, sad subject matter...
    +1
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    @SylverReZ, he's in a bunch of great films. Anyway Syl, and everyone else, I gotta jet. Love you guys so much, great to keep up with you in a chatroom!!!!
    +2
  • SylverReZ @ SylverReZ:
    @The_Dizzy_Vizzy, Yeah, take care man. You're an awesome dude.
    +1
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    @K3Nv2, that was awful. I hope they catch that piece of shit and stick him in a cell to the day he dies...
  • The_Dizzy_Vizzy @ The_Dizzy_Vizzy:
    @SylverReZ. awww, I'm touched (but not like that)
    !!!
    +1
  • K3Nv2 @ K3Nv2:
    He was a ceo of an insurance company both equal pieces of shit
  • K3Nv2 @ K3Nv2:
    Had chili for dinner just to piss off the dentist tomorrow
    +1
    K3Nv2 @ K3Nv2: Had chili for dinner just to piss off the dentist tomorrow +1