dylifire / gnuboy-gx

Automatically exported from code.google.com/p/gnuboy-gx
0 stars 0 forks source link

Original Video Mode #8

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm not sure if this project is still alive, but if you plan to release one 
more version someday, it would be really nice to have an option to use the 
original video mode, like your others emulators, but mainly like smsplus-gx.

Gamegear looks really good using the original mode on smsplus, and since the 
resolution is the same as Nintendo's Game Boy, I'm think gnuboy would benefit 
tremendously from using the original mode, since due to the really low 
resolution of Gameboy, it's really hard to find a satisfactory screen 
configuration.

So, I think this feature would be a good way to wrap up this project, since 
Gameboy full emulation is already achieved, but one of the better features of 
emulating games on Wii are not implemented yet.

Thanks.

Original issue reported on code.google.com by thiagoalvesdealmeida@gmail.com on 20 Jul 2010 at 2:56

GoogleCodeExporter commented 8 years ago
1/ Even if the Game Gear screen size is 160x144, the video resolution is still 
256x192 with colored borders surrounding the screen. It looks good on Game Gear 
because it has the same video output and resolution as the Master System and it 
was perfectly possible to connect the console to a TV to get the same result. 
But try to upscale the GG screen and set it to use original mode, it looks 
awful.

2/ Gameboy resolution is not the same at all, it is 160x144 with square pixels 
(where as SMS/GG had non-square pixels), which is not compatible with any TV 
standard, hence why it need to be adjusted for a TV screen. Putting original 
mode support would be possible but totally inaccurate and would not bring any 
benefits imo, just "scanlines" to make the screen sharper but that's not how 
gameboy games were designed to be displayed anyway. On the contrary, LCD 
filtering would probably be the thing to implement.

Original comment by ekeeke31@gmail.com on 20 Jul 2010 at 4:01

GoogleCodeExporter commented 8 years ago
Oh, I see...thanks for clarifying. I was used to play Gameboy on TV using 
320x240, with no upscaling, just with the picture centered at the screen and it 
looked great. But since Wii is not really capable of displaying a lower 
horizontal resolution, it should be hard to adjust the screen at 240p.

What about Super Gameboy? I know gnuboy don't support it. But isn't possible to 
display the picture like this? http://bmf.rustedlogic.net/misc/zeldadx.png

I know that Super Gameboy add borders even in games that were not optimized to 
use this device.

Original comment by thiagoalvesdealmeida@gmail.com on 20 Jul 2010 at 6:11

GoogleCodeExporter commented 8 years ago
Maybe yes, I think this already displayed like this (in scaled , non-stretched 
mode at least), with additional filtering of the Wii 480i rendering. Borders 
are rendered by Super Nintendo hardware. I leave this opened since it can 
easily be added, I'm not really interested enough in working on this emulator 
anymore though.

Original comment by ekeeke31@gmail.com on 21 Jul 2010 at 6:31

GoogleCodeExporter commented 8 years ago
It's good to know it's possible. Thanks for leave this open. Maybe it could 
inspire someone. 

Original comment by thiagoalvesdealmeida@gmail.com on 21 Jul 2010 at 3:20

GoogleCodeExporter commented 8 years ago
By the way, I don't think Super Gameboy emulation is really necessary just to 
have borders. It's possible to just add black borders, like Visual Boy Advance 
does. 

VBA-M with borders turned on can also reproduce colored borders surrounding the 
screen, like Gamegear.

This is how a sample of VBA source code looks like:

gbBorderOn = 0; // GB borders always off

                        if(gbBorderOn)
                        {
                                srcWidth = 256;
                                srcHeight = 224;
                                gbBorderLineSkip = 256;
                                gbBorderColumnSkip = 48;
                                gbBorderRowSkip = 40;
                        }
                        else
                        {
                                srcWidth = 160;
                                srcHeight = 144;
                                gbBorderLineSkip = 160;
                                gbBorderColumnSkip = 0;
                                gbBorderRowSkip = 0;
                        }

Original comment by thiagoalvesdealmeida@gmail.com on 21 Jul 2010 at 6:05

GoogleCodeExporter commented 8 years ago
VBA code is no help for that, those are 2 different emulators, those settings 
makes absolutely no sense for gnuboy ;-)

Anyway, setting black borders is VERY easy and it's already done if you choose 
Aspect = SCALED or Aspect=ORIGINAL. SCALED is just a zoomed version of the 
original 160x144 picture but still with borders around the screen.

Setting colored borders is more tricky but still possible using GX. Contrary to 
Game Gear or Master System though, I don't think the border color is original 
part of GBC video emulation, at least it's not emulated by gnuboy.

Original comment by ekeeke31@gmail.com on 22 Jul 2010 at 8:25

GoogleCodeExporter commented 8 years ago
Yes. I know. I was just trying to show how VBA use the extra resolution of the 
SNES to create borders. 

I can also see that gnuboy already have black borders (scale factor 1x). I was 
just wondering how this could be done using 240p instead of 480i. Using a scale 
factor of 1x on 640x480 (interlaced mode) is not the same as using it on 
640x240 (progressive mode). The picture in this last case would squashed.

I remember that sometime ago FCEUltraGX was using a wrong horizontal 
resolution, producing scaling artifacts. This could be solved reducing the 
horizontal zoom to 80% (so, do the math 320*0.8=256 or 640*0.8=512), creating 
black borders, but solving the problem.

Maybe the same could be done with Gameboy, since the horizontal resolution 
(160) is 50% of 320. And the vertical resolution (144) is 60% of 144. 

You know better how all this works.

About colored borders on Gameboy, I didn't liked it. Old GB games just use a 
white border, and GBC games use all kind of odd color choices. A black border 
looks much better.

Original comment by thiagoalvesdealmeida@gmail.com on 22 Jul 2010 at 3:29

GoogleCodeExporter commented 8 years ago
I mean, the vertical resolution of Gameboy (144) is 60% of 240. 

Original comment by thiagoalvesdealmeida@gmail.com on 22 Jul 2010 at 6:05

GoogleCodeExporter commented 8 years ago
This is not the same here and not required:

- original aspect is already doing raw 2x upscale, outputs a 320x288 image 
centered on screen, without any filtering or artefacts. This is the best you 
can get.

- scaled aspect tries to fit the screen vertically while keeping the original 
aspect ratio of gameboy (~1:1 screen), this outputs a 500x448 image with 
horizontal black borders on both side. Filtering is required so you don't have 
artefact because of horizontal AND vertical upscaling.

- stretched aspect fills the whole 4:3 TV screen, this outputs a 640x448 image 
which does not respect the original gameboy aspect ratio but make some people 
happy because there are no borders. Like the above option, filtering is 
required because of odd upscaling.

And for the record (even if it's quite off-topic), FCEUGX was NOT using the 
wrong resolution: you don't seem to understand that the notion of "pixels" or 
"resolution" is completely dependent on the systems when speaking about analog 
video signals. For example, 256 NES pixels have quite the same aspect as 640 
Wii pixels when displayed on TV, hence why the rendered image need to be 
upscaled . By using 80% scale value, you basically disabled upscaling (the 256 
'NES' emulated pixels are simply doubled), it may looks better (because 
hardware filtering is switched off in this case) but it's definitively not 
accurate (NES consoles never displayed such black borders on the sides off TV 
screen).

Now, regarding non-interlaced mode support (240p), which is what your issue is 
related to, this can easily be added like in any other emulators (it's just a 
matter of configuring the Wii video hardware and reduce vertical scaling, not 
complicate percentage caclculation like you are doing is required), it 
generally outputs a sharper image but the gameboy LCD screen was not like that 
anyway.

Original comment by ekeeke31@gmail.com on 24 Jul 2010 at 1:54

GoogleCodeExporter commented 8 years ago
I confess that all I know about video resolutions comes from the PC 
environment, reprogramming a video card to produce very low resolutions 
(including 256x240), using a software called soft15khz.

If you have, for example, a NES game, you can achieve a "pixel-perfect" display 
on Windows XP running at the actual native resolution (256x240 - unstretched) 
or 512x240 (upscaled - maybe a bit narrower, but a lossless duplicate). Wii can 
also reproduce the exact same picture (I did compare - same TV and cables), but 
using a different horizontal resolution (720 - from what you told me). I have a 
hard time understanding how this is possible, but I will try. Let's see...

1 - Wii can output a resolution using a different way compared to a PC running 
Windows, right? If I select 720x240 on Windows, it would display 720 active 
pixels per line horizontally, and 240 active pixels per line vertically – no 
other choice. But when you display 720x240 using Wii's hardware, you can use 
720 horizontal pixels to show stuff or change the number of active pixels on 
the fly, so, if you want to display a Genesis game, you will program the 
emulator to use 640 active pixels centered on a 720 resolution (with 80 black 
pixels on the surrounding area). You can't normally do that on a PC using 
Windows. Is that all correct? 

2 – If Wii is using 720x480, but with 640 active pixels, it would be just 
like a PC displaying 640x480 for all purposes, right? I mean, if I want to 
stretch a picture to fullscreen, it will be stretch to 640 (and not 720), 
right? So, the others 80 pixels are basically "dead".

3 – There is an option on FCEUGX and SNES9XGX called "zoom". The real 
function of this option is to change the number of active pixels?

About FCEUGX using or not the wrong resolution, before a recent change, it was 
using 640 instead of 512. If you use 640 upscaled without filtering you will 
introduce artifacts to the graphics presentation, some pixels will be displayed 
twice, when you scroll such an image, you will introduce shivering, pixels will 
start to alternate between their 1 and 2-pixel stretched variations. You can 
only hide this using a filter (blurring the picture - a quality degrading 
solution). I told you that by using 80% scale value you could fix that without 
the need to use a filter, but I know it's not accurate since it would display 
black borders. Anyway, this problem is now fixed, since FCEUGX is now using 
512. That gives me another question… 

4 – If you define 512 active pixels on Wii, why you can't see visible black 
pixels? 640 active pixels I can understand, but why not with 512? That's 
because horizontal scaling always happens in video hardware if the horizontal 
resolution is less than 720?

5 – Are there two kinds of upscaling on Wii? One using the GPU, the other 
using the video encoder chip. You can disable only the GPU upscale, right?

Original comment by thiagoalvesdealmeida@gmail.com on 25 Jul 2010 at 5:04

GoogleCodeExporter commented 8 years ago
1. Don't know much about PC video cards, but I'm pretty sure you can also use a 
720 pixels wide framebuffer on Windows and only fill a limited range in the 
middle. This is exactly the same thing on Wii except you only need a 
framebuffer as wide as your defined active screen area and video hardware will 
take care of the borders. The Wii always output a 720 pixels wide video signal: 
within that range, you can define your active screen area and the content of 
the framebuffer will be displayed there. Anything else outside will be 
displayed black, there is nothing complicated or special with that.

2. This question does not make much sense. There are no definition of 
"fullscreen stretch", this depends on TV. Pixels are not 'dead', there are 
here, only hidden by TV edges. We used 640 pixels wide active screen because 
this is approximately what most TV can show without overscan. Modern TV shows 
more which would result in tiny vertical bars, hence why the usual active 
screen is generally set a little larger than 640 pixels. And to answer your 
question, no it will be different because pixels have different shape depending 
on the original resolution. Think the video signal as a continous line with a 
FIXED length: this line can hold a certain amount of information ("pixels"), 
the number of distinct pixels depends on pixel clock of the hardware that 
generated the video signal, which give the resolution. The less pixels you have 
on a line, the wider they appear on screen. Again, Wii always output 720 pixels 
(incl. black pixels) so they have a specific and constant shape.

3. No, this option is to let you change the amount of scaling between the 
original image generated by the emulator (a 256 pixels wide texture) and the 
final image rendered by GX hardware into the framebuffer. The active screen 
width is generally fixed (at least in NES/SNES emus). However, you can change 
how GX will scale the original image up to the framebuffer width. If the 
original image is not upscaled completely (80% for example), GX will render 
black pixels around the image.

4. Probably because 512 is the width of the framebuffer and the active video 
width is still 640 (or a little more). In that case, horizontal scaling does 
not happen in GX (well, it only "doubles" the 256 pixels wide image to fill the 
framebuffer) but in the video hardware. Indeed, if the framebuffer width is 
smaller than the defined active width, video hardware will upscale the image 
horizontally up to the active width. This method introduces generally less 
filtering than GX scaling and also don't show any scaling artefacts.

5. Answered above. Using GPU (GX), you define the width of your framebuffer and 
you can scale any image as you want (anything below the framebuffer width will 
render black pixels around the image and anything above will not be rendered). 
The video hardware uses the content of this framebuffer to fill the active 
video area you defined: the framebuffer width MUST be equal or less than the 
active video width. If it is less then horizontal scaling occurs. So basically, 
it's up to the developper to define both framebuffer and video width.

Original comment by ekeeke31@gmail.com on 26 Jul 2010 at 10:27

GoogleCodeExporter commented 8 years ago
OK. I'm starting to understand...

You have the horizontal resolution fixed at 720. But some pixels are hidden by 
TV overscan (SDTV, since Wii was mostly designed to work with it). So, 
practically, 640 is what you really see on the TV, and that's why most games 
(and homebrew) use 640 active pixels.

A few more questions:

1. Does the emulator render the screen into a textured and pre-transformed quad 
so you can position it and scale it in any way you want? 

2. With SMS-Plus (256x192), for example, you just doubles the horizontal 
resolution (256 to 512) and leave the vertical resolution untouched? In that 
case, the video hardware will upscale the horizontal resolution (512) to the 
defined active width (640, I guess). But what about the vertical resolution 
(192), it will be also upscaled by the video hardware to 240?

Original comment by thiagoalvesdealmeida@gmail.com on 27 Jul 2010 at 2:51

GoogleCodeExporter commented 8 years ago
1. yes, exactly

2. in non-interlaced (original) mode, the height is left untouched while in 
interlaced mode, it is doubled. vertical upscaling can only be done within the 
GPU rendering or during the copy from GPU to the framebuffer, if you configured 
it. Video hardware does not upscale the framebuffer vertically, it can only 
upscale horizontally, so the framebuffer height must be properly configured.

Original comment by ekeeke31@gmail.com on 27 Jul 2010 at 6:21

GoogleCodeExporter commented 8 years ago
Really really thank you for answering all those questions.

I still think that there is no better way of display low-resolution 2D graphics 
than using 240p on a CRT SDTV with component cables. Even old PC games, 
designed to be played on a PC monitor, looks much better on TV. Maybe it's hard 
for you to see the difference since your are probably using a progressive 
display, but I think there is no contest between using an interlaced and 
non-interlaced mode when dealing with emulators. Of course that when using the 
original mode with Gameboy you probably have to disable (vertical) scaling, but 
I think that's the point.

About how gameboy games were designed to be displayed, I think it's very 
subjective. 2D graphics looks equally good when displayed non-scaled on a LCD 
screen and TV. Well, most GBA games have vibrant colors to compensate for all 
those people using GBA's without backlight, but that can be corrected changing 
your TV settings.

And since most SNES games don't really take in account the "analog stretch" 
that happens when you display 256x224 on a 4:3 TV, it makes you really wonder 
if Gameboy games were really designed with it's particular aspect ratio and LCD 
screen in mind.

Anyway, thanks for leaving this issue open. It's good to know it's possible and 
easy, so it could happen in the future. This can wait.

Original comment by thiagoalvesdealmeida@gmail.com on 28 Jul 2010 at 2:20