Widescreen mode and kos ?

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
patbier
DC Developer
DC Developer
Posts: 152
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Widescreen mode and kos ?

Post by patbier »

Hello, i wonder how can we give a widescreen mode support in a game made with KOS ? I currently use a 640*480 mode in vga, pal and ntsc.
Is it possible to set the pvr_init to use a resolution of 740/416 for example to draw sprites, etc... and then the video output fits it in 640 * 480 ?

Thanks for help :)
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Widescreen mode and kos ?

Post by BlueCrab »

If you were to try to do widescreen-type resolutions, you'd have to come up with a vid_mode_t corresponding to the settings you want to make. This has things like the pixel clock, border information, and other fun stuff in it. Look at the <dc/video.h> header file for the structure, and the kernel/arch/dreamcast/hardware/video.c file for the ones that are built-in to KOS. Once you have the structure all set up, you should be able to simply call vid_set_mode_ex with the structure you've set up (make sure you do this BEFORE doing any video related or PVR related stuff). I've never really messed around with that kind of stuff, so I can't be of much more assistance than that...

Also, you'd have to tweak the PVR init, since it assumes 640x480 by default (that works fine for lower resolutions, but won't work for higher ones). One thing to note (I believe) is that the PVR mode MUST be a multiple of 32 in each direction (so you might have to set it slightly larger than it would otherwise be).

EDIT:
I just noticed that there is a 768x480 mode in the video.c file. Perhaps that will work for what you want and everything divides nicely by 32, so it should be able to be used with the PVR (you still would need to tweak the init for the PVR though).
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

OK, thanks for the answer.
It is a solution, but the 768 * 480 doesn't exist for the VGA mode.

So i wonder if we can do, as I remember from openGL : namely drawing a scene in 740 * 416 for example, and then it renders in 640 * 480. So the tv or the monitor has just to strech to have a 16/9 display.

By the way, is a homebrew game offers the 16/9 option ? And in official game, how did they do ?
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Widescreen mode and kos ?

Post by BlueCrab »

It should be fairly easy to adapt the NTSC version to work with VGA, I'd think anyway.

I don't remember any 16x9 games for the Dreamcast, but then again, I didn't have a 16x9 TV until after the end of the Dreamcast's commercial life. I also don't think I've ever seen any 16x9 homebrew.
Ayla
DC Developer
DC Developer
Posts: 142
Joined: Thu Apr 03, 2008 7:01 am
Has thanked: 0
Been thanked: 4 times
Contact:

Re: Widescreen mode and kos ?

Post by Ayla »

MSR and Toy Commander have options for widescreen TVs. But I suppose even in widescreen mode, they use 640x480.
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

From what I read, the 768 * 480 is not a standard vga mode, so i don't think it will work, but if someone can give me the good settings i can try.
The wii is using a 720 * 480 resolution but with a yuv cable.
The xbox 360 can be set up in 848 * 480 with a vga cable, i test this resolution on my tv and it works. Note that in this resolution, the screen is not fully displayed, there's a black border in the right side of the screen. I asked my tv to adjust, but it still has this black border.

The best for me would be to find a widescreen resolution who works in pal, ntsc and vga at the same time
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

Ok, I try to make the custom 768 * 480 VGA 60 Hz

Code: Select all

#include <dc/pvr.h>
#include <dc/video.h>

static pvr_init_params_t pvr_params = {
    /* Enable Opaque and Opaque modifiers. */
    { PVR_BINSIZE_16, PVR_BINSIZE_16, PVR_BINSIZE_16, PVR_BINSIZE_16,
      PVR_BINSIZE_0 },
	512 * 1024
};

	/* 768x480 VGA 60Hz (not working for the moment) */
	/* DM_768x480_VGA */
	vid_mode_t vid_768 =
	{
		DM_768x480,
		768, 480,
		VID_INTERLACE,
		CT_VGA,
		0,
		524, 857,
		96, 18, // surely here to change
		0x15, 0x104,
		0x2e, 0x345,
		0x24, 0x204,
		0, 1,
		{ 0, 0, 0, 0 }
	}    ;

int main(int argc, char *argv[]) {
    vid_mode_t vidMode;
    pvr_init(&pvr_params);
    memset( &vidMode, 0, sizeof(vid_mode_t));
    memcpy( &vidMode, &vid_768, sizeof(vidMode));
    vidMode.pm = PM_RGB565;
    vidMode.cable_type = vid_check_cable();
    vid_set_mode_ex( &vidMode);

    /* Display something */
    while(!check_start())   {
        do_frame();
    }

    return 0;
}
This shows something (like you set a bad rgb setting, you can see some part of the textures, but not well aligned) but my monitor says it is in 640 * 480.
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Widescreen mode and kos ?

Post by PH3NOM »

Yeah I was wondering why KOS only included 768x480 interlace and not progressive...
I hope we can get this mode to work, I would like to use it also...

And, I thought the PVR could do 24bit display mode? I dont see a RGB888 or similar in PVR.h...?
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5948
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has thanked: 10 times
Been thanked: 0
Contact:

Re: Widescreen mode and kos ?

Post by Christuserloeser »

This is a bit OT but:

I think that you could do the 768x480 mode in software or manually (redraw everything in that ratio) and then output it in 640x480 VGA.

If the user then stretches it via your TV's video modes, it will look correct again.

That's how I think BlackAura explained how it's done in commercial Dreamcast games.
Insane homebrew collector.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Widescreen mode and kos ?

Post by BlueCrab »

PH3NOM wrote:Yeah I was wondering why KOS only included 768x480 interlace and not progressive...
I hope we can get this mode to work, I would like to use it also...

And, I thought the PVR could do 24bit display mode? I dont see a RGB888 or similar in PVR.h...?
The PVR can output RGB888, but it cannot take in textures in RGB888. It can, however, do 4bpp/8bpp palleted textures with RGB888 entries, but then you're limited to only 16 or 256 colors per texture.
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

Christuserloeser : Yes, I tried F355 and the widescreen is 640 * 480 like the 4/3. I'm sure the other widescreen games do the same. In 3d game, it seems quite easy.

In my 2d game, i'll have to use a ratio for each texture, which is doable, but, i'd like another solution. Indeed, we made too many efforts to have pretty textures, to have a good renderer. This solution will give "blur" as textures will be reduced, then enlarged.

If we achieved in, the resolution solution won't affect the quality.
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7497
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Widescreen mode and kos ?

Post by Quzar »

The other way to do it that I've found (in 2D) is to have a separate set of textures for widescreen and have them be 'thinner'. By doing this you avoid some of the distortion of the original squashing before the TV expands it. The only issue to deal with is that many TVs that do a widescreen stretch do not do it evenly across the whole image (so the very edge pixels may still be 1:1 then the ones in the center of the screen may be 2:1, very annoying).
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

Thanks for the idea Quzar.

By the way, this morning I have tested the 768*480 resolution in PAL and NTSC on my TV, and it doesn't work : it is still 640 * 480 and the image is no good (distorsion).
Perhaps it is my hardware because i'm using a vga box which has a tv / pc option.

Does someone has already tested the 768*480 resolution ?
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Widescreen mode and kos ?

Post by PH3NOM »

patbier wrote:Thanks for the idea Quzar.

By the way, this morning I have tested the 768*480 resolution in PAL and NTSC on my TV, and it doesn't work : it is still 640 * 480 and the image is no good (distorsion).
Perhaps it is my hardware because i'm using a vga box which has a tv / pc option.

Does someone has already tested the 768*480 resolution ?
I tested this mode a few days ago, and at least nullDC reports the screen is accurately set to 768x480.

But all I did was set the video mode to DM_768x480, nothing more. What else needs to be done, BlueCrab?
BlueCrab wrote: Also, you'd have to tweak the PVR init, since it assumes 640x480 by default (that works fine for lower resolutions, but won't work for higher ones). One thing to note (I believe) is that the PVR mode MUST be a multiple of 32 in each direction (so you might have to set it slightly larger than it would otherwise be).

EDIT:
I just noticed that there is a 768x480 mode in the video.c file. Perhaps that will work for what you want and everything divides nicely by 32, so it should be able to be used with the PVR (you still would need to tweak the init for the PVR though).
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Widescreen mode and kos ?

Post by BlueCrab »

Hmm, I could've sworn that I remembered seeing 640x480 hardcoded somewhere in the PVR initialization, but I'm not seeing it now... I guess it should just work after setting the video mode appropriately.

Also, never trust NullDC for testing more interesting things like this. Emulators always have their own way of handling things that may or may not act the same as the hardware. As a recent topic on this forum pointed out, sometimes things work perfectly on the hardware that barf on the emulators. The reverse is also true.
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

Ok thanks for the answer, that's also the explanation for the 768*480 mode which didn't work in VGA, in my first tests.
I hope the 640 * 480 is not the maximum hardware resolution blocked by something.
By the way, if someone put the 768*480 in KOS code, I guess he tested the resolution at this moment, and if he kept it in means that it worked.

Hope BlueCrab find the function which blocks. Or just find a way I can explore.
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

Another tests, I thought it worked, but not really...

I tried with the vid_set_mode before the pvr_init and after, and in VGA and NTSC, i have a good picture :

Code: Select all

    vid_set_mode(DM_768x480_NTSC_IL,PM_RGB565);
    pvr_init(&pvr_params);
    vid_set_mode(DM_768x480_NTSC_IL,PM_RGB565);
But this is not 768*480 because the display in the x coordinate is like from 64 to 704 !

namely :

Code: Select all

-----------------------------------------
|                       0                |
|                                        |
|64                                   704|
|                                        |
|                    480                 |
-----------------------------------------
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

BlueCrab : any idea to correct this ?
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Widescreen mode and kos ?

Post by BlueCrab »

I've never even looked at the 768x480 modes, so no, I really don't have any ideas.
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has thanked: 0
Been thanked: 0

Re: Widescreen mode and kos ?

Post by patbier »

Playing with settings, I just had something bigger than 640 * 480 !

These settings give 720x576 vga.

Code: Select all

	//720x576 VGA 50Hz
	vid_mode_t vid_768 =
	{
		DM_768x480,
		768, 480,
		0,
		CT_VGA,
		0,
		[b]624, 863,[/b]
		96,40,
		0x18, 0x104,
		0x36, 0x34b,
		0x2c, 0x26c,
		0, 1,
		{ 0, 0, 0, 0 }
	}    ;
But it's strange as my monitor says that it is a 720x576 in 50hz at 31.2Khz, but i can see my complete 768x480 picture displayed. So the setting which gives the resolution is the "uint16 scanlines, clocks;". (i put them in bold above)
And if you compare this setting between the 768*480 mode and the 640*480 mode in NTSC for example, you'll see that this setting is the same : 0x20C, 0x359, namely 524,857 in decimal.
That's why the 768 * 480 doesn't work and displays in 640 * 480 !

So, who can help me to understand how to calculate the scanline / clocks settings ?
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
Post Reply