DCEmulation

The Dreamcast Homebrew Community Online
It is currently Tue Sep 07, 2010 2:51 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Widescreen mode and kos ?
PostPosted: Sat Jul 17, 2010 1:17 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
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 :)

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sat Jul 17, 2010 11:55 am 
Offline
The Crabby Overlord
The Crabby Overlord
User avatar

Joined: Mon May 27, 2002 9:31 am
Posts: 2407
Location: Maryland
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).

_________________
Image


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sat Jul 17, 2010 12:11 pm 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
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 ?

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sat Jul 17, 2010 12:59 pm 
Offline
The Crabby Overlord
The Crabby Overlord
User avatar

Joined: Mon May 27, 2002 9:31 am
Posts: 2407
Location: Maryland
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.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sun Jul 18, 2010 12:17 am 
Offline
DCEmu Fast Newbie
DCEmu Fast Newbie

Joined: Thu Apr 03, 2008 5:01 am
Posts: 20
MSR and Toy Commander have options for widescreen TVs. But I suppose even in widescreen mode, they use 640x480.


Top
 Profile E-mail  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sun Jul 18, 2010 2:52 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
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

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sun Jul 18, 2010 9:22 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
Ok, I try to make the custom 768 * 480 VGA 60 Hz

Code:
#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.

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sun Jul 18, 2010 10:33 am 
Offline
DCEmu Fast Newbie
DCEmu Fast Newbie

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 21
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...?


Top
 Profile E-mail  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sun Jul 18, 2010 11:15 am 
Offline
Moderator
Moderator
User avatar

Joined: Wed Aug 27, 2003 10:16 pm
Posts: 5206
Location: DCEvolution.net
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.

_________________
I reject the reality and substitute my own.


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sun Jul 18, 2010 11:38 am 
Offline
The Crabby Overlord
The Crabby Overlord
User avatar

Joined: Mon May 27, 2002 9:31 am
Posts: 2407
Location: Maryland
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.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Sun Jul 18, 2010 12:16 pm 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
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.

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Mon Jul 19, 2010 7:38 pm 
Offline
Dream Coder
Dream Coder
User avatar

Joined: Tue Jul 30, 2002 10:14 pm
Posts: 7317
Location: Behind NeoDC
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


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Tue Jul 20, 2010 12:42 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
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 ?

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Tue Jul 20, 2010 5:38 pm 
Offline
DCEmu Fast Newbie
DCEmu Fast Newbie

Joined: Fri Jun 18, 2010 7:29 pm
Posts: 21
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).


Top
 Profile E-mail  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Tue Jul 20, 2010 6:29 pm 
Offline
The Crabby Overlord
The Crabby Overlord
User avatar

Joined: Mon May 27, 2002 9:31 am
Posts: 2407
Location: Maryland
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.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Wed Jul 21, 2010 4:29 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
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.

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Wed Jul 21, 2010 5:28 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
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:
    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:
-----------------------------------------
|                       0                |
|                                        |
|64                                   704|
|                                        |
|                    480                 |
-----------------------------------------

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Thu Jul 22, 2010 11:29 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
BlueCrab : any idea to correct this ?

_________________
Alice's programmer


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Thu Jul 22, 2010 3:48 pm 
Offline
The Crabby Overlord
The Crabby Overlord
User avatar

Joined: Mon May 27, 2002 9:31 am
Posts: 2407
Location: Maryland
I've never even looked at the 768x480 modes, so no, I really don't have any ideas.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Widescreen mode and kos ?
PostPosted: Fri Jul 23, 2010 1:06 am 
Offline
DC Developer
DC Developer

Joined: Thu Aug 28, 2003 11:25 pm
Posts: 97
Playing with settings, I just had something bigger than 640 * 480 !

These settings give 720x576 vga.


Code:
   //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 ?

_________________
Alice's programmer


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group