Homebrew SNES9x for Old 3DS

bubble2k16

Well-Known Member
OP
Member
Joined
Jul 25, 2016
Messages
467
Trophies
0
XP
2,118
Country
Senegal
...I think I must be the only one who likes the new font. :(

I'll admit the change in font wasn't all that great either, I was actually quite enjoying the bitmap font with no smoothing.
If you wanna try a different font, maybe try Droid Sans?
https://fonts.google.com/specimen/Droid+Sans
Don't forget to include the license somewhere in the release, like a readme or a screen on the interface.

I tried a number of fonts, including Open Sans, Roboto but they all look terrible at that size. I also find the original fonts horrible. :rofl2: But given the feedback, I'll probably use the original as default, and allow you to select from one of the two. I'll see.

Maybe the odd hi-res quirks are a result of the fixes for games like Kirby's Dreamland 3, but I doubt it. It looks more like a tiling issue. I don't know what sort of games that might affect.
The mosaic effect issue is a broader issue though as a great deal of SNES games use it.

The mosaic can never be fixed as DiscostewSM mentioned. We had to sacrifice that for using the GPU to boost performance in this Snes9x port. Though, I've imagined how it would be like if we implemented some form of alternative mosaic effect...

This is all just suggestions but anything that could get the 4:3 modes sharper than they currently are would definitely help a ton.

Whether we do nearest neighbour and linear interpolation, there's no impact to performance because it's all handled by the GPU. But unfortunately, the 3DS doesn't have a pixel shader in its GPU to implement what you mentioned, so there's no way to do this in hardware.

In theory we could do what pixellate did in software, performance will suffer, and it will not be worth it.
 

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,464
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,315
Country
I think, just maybe the first scan line is not supposed to be rendered. :) Seems like its documented in some of the online knowledge bases. I think I'll have to avoid rendering the first scanline then.
I think something like this might be right. If you compare my Snes9x 3DS screenshot against a different screenshot taken in bsnes:

0V6GDYu.png

605ad732-eab8-11e6-8402-906c7ac07bb4.png

You can see that in bsnes, the HUD is separated from the gameplay area by two lines (four lines in this 2* scale screenshot), whereas in Snes9x 3DS, only one line (two here) separates the two screen segments. So it seems like the gameplay area should be moved up by one line (skipping the first scanline) while the HUD remains in place. No idea how complicated a situation that is, but desktop Snes9x versions seem to have the same two-pixel gap.

EDIT: Desktop Snes9x 1.43 does have the same behavior as yours here, with the one-pixel gap only. Regardless, it's such a minor non-issue that it probably isn't even worth fixing this part.
 
Last edited by Vague Rant,

Canzah

Well-Known Member
Member
Joined
Jul 8, 2012
Messages
492
Trophies
0
XP
1,410
Country
United Kingdom
In theory we could do what pixellate did in software, performance will suffer, and it will not be worth it.
Well then blinear filtering like the one I showcased is still the second best thing and still definitely better than what it looks like right now, unless it's just blurrier due to the AR being screwed and will look on par with the PC 4:3 screen once it's fixed.
Would be nice to have option to switch between nearest and blinear like on PC as well.
Pity about 3DS crappy GPU not supporting shaders though.
 

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,464
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,315
Country
Whether we do nearest neighbour and linear interpolation, there's no impact to performance because it's all handled by the GPU. But unfortunately, the 3DS doesn't have a pixel shader in its GPU to implement what you mentioned, so there's no way to do this in hardware.
I'm not sure what the shader is doing or anything, but one scaling trick I've seen done to get a nicer image when doing non-integer scaling is to do an integer scale to make the image larger, then do a linear scale to get it to the shape and size you're looking for. As a quick mockup demonstration:

FOub7hB.png

Original Screenshot (256*224)

FheW9OE.png
mBYKDFF.png

Linear from 256 pixels wide up to 292 wide <-- (292*224) --> Nearest-neighbor from 256 to 512, then linear to 292​

They're obviously quite similar, but a close look will show that the one on the right is slightly more sharp than the one on the left. This is particularly noticeable in the text on the HUD, "STOCK", "SCORE", "SPEED" and "POWER". If a scaling operation like this can be done for free on the GPU, it might be nice, but I have no idea whether this is plausible.

EDIT: Looking more closely, I see that this is exactly what the shader @Canzah suggested is doing. Sorry for the pointless repetition, I didn't realize this was something a shader had to do. I don't know anything about shaders. /EDIT

Also, while I've got an audience, I'm going to be obnoxious about aspect ratios for a second. It's generally agreed that the NES and SNES have a pixel aspect ratio of 8:7. This means that each pixel is an 8*7 rectangle, not that the entire picture is in 8:7 ratio. This means the correct way to get the original systems' aspect ratio is to multiply 256 (the width) by 8/7. The result is 292.571428571429*, so you'd want to scale the image to 292*224, or 292*239 for games that run in that mode. This is the scaling I've used for HyperZone, above. Check out that nice looking circle enemy in the top left. Mm-mmm, circular. Stretching to a full 4:3 ratio of 320*224/239 results in an image that's actually wider than intended/it would have appeared originally by a substantial amount.

* I know that 292.571428571429 rounds up to 293, not 292, but odd numbers are dumb and will result in a very slightly off-center image as a trade off for a positively invisible improvement in aspect ratio. But this is personal preference, people should like whatever things they like, etc.

The other thing to mention is people have been advocating different aspect ratios for when the games are running 224 tall vs. 239 tall, but this wouldn't be accurate to the way the SNES worked. Even when running at 224p, the other 16 lines still "exist". They're still part of the signal being sent to the TV, it's just that they're left blank. Any calculations of aspect ratio should be based on the full 240 pixels in the video signal, not the resolution of any individual game (224p/239p). Basically, if you want the correct aspect ratio, the SNES should always be 292 (or 293) wide.
 
Last edited by Vague Rant,

bubble2k16

Well-Known Member
OP
Member
Joined
Jul 25, 2016
Messages
467
Trophies
0
XP
2,118
Country
Senegal
Well then blinear filtering like the one I showcased is still the second best thing and still definitely better than what it looks like right now, unless it's just blurrier due to the AR being screwed and will look on par with the PC 4:3 screen once it's fixed.
Would be nice to have option to switch between nearest and blinear like on PC as well.
Pity about 3DS crappy GPU not supporting shaders though.

Oh recently, I actually tried doing nearest neighbour some time back because I wanted to provide that option too. But when I tried it on a real 3DS the output was absolutely unacceptable. It has jagged edges every few lines. I have no idea why and never spent much time to figure it out, so I went back to only linear interpolation. And the 3DS only has nearest and linear, no bilinear sadly.

EDIT: Desktop Snes9x 1.43 does have the same behavior as yours here, with the one-pixel gap only. Regardless, it's such a minor non-issue that it probably isn't even worth fixing this part.

It could very well be a timing issue. v1.43 isn't known for having the most accurate timing. That's why we do see some scan line artifacts in certain games. The later versions are better, but are very slow.

I'm not sure what the shader is doing or anything, but one scaling trick I've seen done to get a nicer image when doing non-integer scaling is to do an integer scale to make the image larger, then do a linear scale to get it to the shape and size you're looking for. As a quick mockup demonstration:

Never occurred to me to do it this way... I'm not quite sure if I have enough 3DS VRAM/RAM to pull this off. I could try but that would have to be after v1.0. The only problem that I have with the image on the right is that the power bars are a little uneven. :)
 

Canzah

Well-Known Member
Member
Joined
Jul 8, 2012
Messages
492
Trophies
0
XP
1,410
Country
United Kingdom
And the 3DS only has nearest and linear, no bilinear sadly.
You're making me hate 3DS' garbage hardware even more. What a piece of plastic crap this is, man I wish Nintendo gave a damn and didn't cut costs all across the board.
Still, I have hope you can figure something out to make the 4:3 output sharper somehow, perhaps with the trick suggested by Vague Rant.
And naturally still waiting for the proper 4:3 aspect ratios for 224p and 239p respectively in general :)
 
  • Like
Reactions: MKKhanzo

bubble2k16

Well-Known Member
OP
Member
Joined
Jul 25, 2016
Messages
467
Trophies
0
XP
2,118
Country
Senegal
You're making me hate 3DS' garbage hardware even more. What a piece of plastic crap this is, man I wish Nintendo gave a damn and didn't cut costs all across the board.
Still, I have hope you can figure something out to make the 4:3 output sharper somehow, perhaps with the trick suggested by Vague Rant.
And naturally still waiting for the proper 4:3 aspect ratios for 224p and 239p respectively in general :)

Well, that's what we have to work with. It still works very well for the 3D games and those that take advantage of the full 400x240 resolution. Emulating lower res consoles and using the 3D hardware in the way we want was certainly never part of their design strategy. :) But I'm happy with what I have.

The 224p/239p is mostly done. I simply added another option to "Stretch Width to 4:3" whilst keeping the height of the output screen, but I haven't published the latest "nightly" yet. But I can't say I happy with the stretching results...
 

Canzah

Well-Known Member
Member
Joined
Jul 8, 2012
Messages
492
Trophies
0
XP
1,410
Country
United Kingdom
The 224p/239p is mostly done. I simply added another option to "Stretch Width to 4:3" whilst keeping the height of the output screen, but I haven't published the latest "nightly" yet. But I can't say I happy with the stretching results...
How exactly are you doing the stretch to width thing? Just telling it to stretch to 299 and 319 respectively?
Since those are such uneven numbers (even if they're actually accurate ones) maybe it would be potentially better if you use 298/318 or 300/320 respectively.
But yeah, without pixelate or blinear it will never look as good as on PC I guess. Hopefully 3DS has enough VRAM to still try the downscaling trick though.
 

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,464
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,315
Country
To be a bit more clear (hopefully) about that aspect ratio stuff, I'm basically saying that the SNES never had a 4:3 aspect ratio, unless you went out of your way to recalibrate your TV to fit the SNES's output. The signal from the SNES was 256-wide (512 on hi-res mode, but the pixels were half as wide, so essentially 256-wide at all times) and 240-tall (remembering that between 1 and 16 of these 240 lines are left blank, i.e. 224 or 239 lines of game).

Thus, at all times (most, but just leave it, ugh), the SNES is outputting an image with a resolution of 256*240, and the pixel clock is timed such that every individual one of those pixels is displayed with an aspect ratio of 8:7. So the end result is that, in "square pixel terms" (not relevant to CRTs, but relevant to us here), the SNES output was always about 292*240, a bit slimmer than true 4:3. Now, on the upside, TVs of the day generally had hefty overscan, it was mostly assumed that at least 5% and as much as 10% of the image would be cut off on the sides and top/bottom, and that's why health bars and stuff are (almost) never rammed right up into the edges, because if it's right on the edge, it runs the risk of being "off the edge of the TV" and thus never seen by the player.

What this all means is that most people probably wouldn't see the black empty areas to the sides and top/bottom, because they would fall in the overscan area of the TV. As such, the full TV would be filled, but not because every pixel was correctly fitting into the 4:3 display, just because a bunch of it was getting lopped off around the edges. Nowadays, we have the virtue of displays that can display every pixel without issue, so we can put them all in the visible area, but that doesn't mean we should scale them to 4:3, because that was never how it worked. For the most part, it was just "292"*224 and the overscan would hide the "missing" 28/16 pixels (and some amount of the actual game's picture) just by the way they operated.

EDIT: To be, perhaps, blunt: the numbers Canzah is quoting as "accurate" widths to display the SNES's "4:3" aspect ratio are incorrect.
 
Last edited by Vague Rant,

bubble2k16

Well-Known Member
OP
Member
Joined
Jul 25, 2016
Messages
467
Trophies
0
XP
2,118
Country
Senegal
How exactly are you doing the stretch to width thing? Just telling it to stretch to 299 and 319 respectively?
Since those are such uneven numbers (even if they're actually accurate ones) maybe it would be potentially better if you use 298/318 or 300/320 respectively.
But yeah, without pixelate or blinear it will never look as good as on PC I guess. Hopefully 3DS has enough VRAM to still try the downscaling trick though.

Nah, I just compute the width as 4 * ScreenHeight / 3. We are going to get 298/318 because of the integer truncation.

--------------------- MERGED ---------------------------

EDIT: To be, perhaps, blunt: the numbers Canzah is quoting as "accurate" widths to display the SNES's "4:3" aspect ratio are incorrect.

So... what is the right ratio? 290x240 isn't exactly 8:7 either.
 

Canzah

Well-Known Member
Member
Joined
Jul 8, 2012
Messages
492
Trophies
0
XP
1,410
Country
United Kingdom
To be, perhaps, blunt: the numbers Canzah is quoting as "accurate" widths to display the SNES's "4:3" aspect ratio are incorrect.
That's all nice and dandy but you're speaking from the SNES analogue display perspective, when we're talking purely digital.
As far as digitalized goes, you can confirm on SNES9x on PC yourself, that you've got games that are strictly 256x224 and 256x239 (I even posted direct screenshots like 2-3 pages back) and as such this is basically what we should be using as base here.
The only thing I can agree with in your post is the way to attain 4:3 image, but because this is such a per-game basis kind of thing that it's hard to agree on any concrete method with digital, and at higher resolutions it's best to just take the 224/239 image and just stretch it with a pixelate shader applied, or better yet, keep aspect ratio and scale by integer if you don't mind the image not filling your screen in full vertically on 1080p displays.
What you said about overscan is indeed true but like I just said, it depended on games. A lot of games did not accout for overscan, while then you have stuff like Chrono Trigger which explicitly accounted for it and didn't even bother displaying anything on the bottom and just put a big black bar there because it would be cropped by overscan anyway.

Nah, I just compute the width as 4 * ScreenHeight / 3. We are going to get 298/318 because of the integer truncation.
Good enough for me.

So... what is the right ratio? 290x240 isn't exactly 8:7 either.
He's talking from analogue display perspective which doesn't even apply here so I'm not sure what he's even trying to say, not to mention being completely wrong about the 290 part.
 
Last edited by Canzah,

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,464
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,315
Country
For the way the emulator works, it would be 292*224 when running 224-line games and 292*239 when running 239-line games. The target isn't to hit 8:7—that's the aspect ratio of the individual pixels, not the image as a whole. At 292-wide, the individual pixels are (calculator time):

292/256*7
=7.984375

So the pixels are 7.984375:7, or basically 8:7, or at least as close as it'll get on a 240p screen like the 3DS. As for the full image's aspect ratio (the 256*240 thing), that means roughly a 3.92:3 aspect ratio. As in, about 2% slimmer than 4:3. Sorry, I know pixel aspect ratios and aspect ratios are a headache.

EDIT: @Canzah Of course we're talking about the analog display of the SNES, because that's how it output its image. If the purpose of an emulator is to emulate the original system, and one of the factors the emulator is attempting to reflect is the aspect ratio of the system, then the answer to "what aspect ratio is the SNES" is "about 3.92:3". It doesn't make any sense to select a new aspect ratio just because we're in the digital realm, now.

This is the aspect ratio thoughtful developers would have designed their games around, i.e. any sort of circles and such should be tuned to be circular when viewed at this specific aspect ratio, the aspect ratio that the SNES used. Why should they look wider now because we have a digital picture?
 
Last edited by Vague Rant,
  • Like
Reactions: Aglaophotis

bubble2k16

Well-Known Member
OP
Member
Joined
Jul 25, 2016
Messages
467
Trophies
0
XP
2,118
Country
Senegal
For the way the emulator works, it would be 292*224 when running 224-line games and 292*239 when running 239-line games. The target isn't to hit 8:7—that's the aspect ratio of the individual pixels, not the image as a whole. At 292-wide, the individual pixels are (calculator time):

292/256*7
=7.984375

If I understand you correctly, regardless of whether SNES outputs 224 or 239, the TV's cathode ray displays same height for every vertical pixel?

Thus in 239 height, there are simply just extra pixels at the top/bottom of the screen (or is it just extra pixels at the top of the screen only, or bottom of the screen only)?
 

Vague Rant

Deceptively cute
Member
Joined
Aug 7, 2008
Messages
2,464
Trophies
2
Location
Melbourne
Website
vaguerant.tumblr.com
XP
3,315
Country
That's correct, @bubble2k16. The same number of lines are displayed (240) in both modes, with the same height for each line, but 15 additional lines are "colored in". My understanding is that it's 8 additional rows on the top and 7 additional rows on the bottom.

EDIT: A couple of reference notes:

Nintendo uses 284-wide scaling to display its NES and SNES Virtual Console games on 3DS (NES and SNES share the same aspect ratio):

85002_MegaMan4_NES-3DS-TBDP-Screen5-ALL.jpg
a.jpg

This is eight pixels slimmer than the 292 which I'm suggesting and slightly inaccurate to the original consoles' pixel clocks, but nobody ever criticized Nintendo's emulators for being too accurate, anyway. ;) I'm kidding around though, 284 looks fine, probably not even noticeably different from 292 to the naked eye. I am curious how Nintendo arrived at this number, though. Did they just eyeball it off a NES/SNES until it looked right? Who knows. Close enough, though.

Perhaps the most iconic example I could think of where a developer tuned their game for the SNES's aspect ratio is Magus's Castle, in Chrono Trigger. There's a big dramatic shot arcing up the castle, with a huge full moon behind the crest. Here's how the moon looks uncorrected (it's partially obscured by the castle, so they didn't bother drawing some of it):

jPuyHy4.png

Incidentally, the moon looks a bit silly in the Nintendo DS port,
because it's a weird dumb oval, exactly as you see it here.​

On the SNES, though, you see this (scaled to have rectangular, 8*7 pixels like the real SNES, i.e. 292-wide mode):

18WUtgS.png

Appropriately dramatic.​

And since I brought it up, here's what it would look like with the Nintendo approved 284-wide scaling instead:

Y2iEwmr.png

Basically the same, it's four pixels slimmer.​
 
Last edited by Vague Rant,

bubble2k16

Well-Known Member
OP
Member
Joined
Jul 25, 2016
Messages
467
Trophies
0
XP
2,118
Country
Senegal
Hope everyone is still holding on to their 11.2 and earlier FWs! Nail-biting times again. Anyway, latest nightly is up.

https://github.com/bubble2k16/snes9x_3ds/raw/master/snes9x_3ds.3dsx
https://github.com/bubble2k16/snes9x_3ds/raw/master/snes9x_3ds.cia

I'm going to a feature freeze now and do a release these couple of days, after clearing the small bugs. Not to worry, I'll still be working on some things before I call it quits. :)

Some things that have been implemented. Not much of a compatibility/emulation-related stuff this round.

1. The notable is probably the new text file format (.CHX) for cheats. The format is simple:
<Cheat Enabled Y/N>,<Game Genie/Pro Action Replay Code>,<Name of cheat, keep it to 20-30 characters)

For eg., I created the following file Gradius III (U).chx:
Y,F38B-6DA4,Start with 31 lives
Y,7E00DC04,Constant Megacrush (enemies die)

(To keep things simple, you can only have .CHX or .CHT for the game, and not both! If you have both, only .CHX will be effective)

2. More cropping options as was discussed earlier in this thread:
a. TV mode, which extends the width to 292 always regardless of the output height
b. 4:3, which extends the width to h*4/3 of the output height
c. Cropped 4:3 fitted to screen
d. Cropped 4:3 full screen

3. Disabled Auto-Save SRAM bug.

4. The settings page's UI is also different - The reason I am doing all these UI stuff in case I can reuse it in another emulator, if I ever get to work on a new one. :)

5. And a number of other minor things...

Feedback is welcome.
 

Canzah

Well-Known Member
Member
Joined
Jul 8, 2012
Messages
492
Trophies
0
XP
1,410
Country
United Kingdom
Hope everyone is still holding on to their 11.2 and earlier FWs! Nail-biting times again. Anyway, latest nightly is up.

https://github.com/bubble2k16/snes9x_3ds/raw/master/snes9x_3ds.3dsx
https://github.com/bubble2k16/snes9x_3ds/raw/master/snes9x_3ds.cia
Amazing job, will get on to testing right now. I wonder if you also restored the old font or added option to switch to the old font, it definitely was clearer than the current arial.
Any reason why we'd need to be on 11.2? My 11.3 A9LH+Luma seems to be working fine. Unless you mean HBL users, in which case I guess they do need to stay on 11.2 for now.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/watch?v=-Eo3Bh06drc