 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
kouky

Joined: 25 Sep 2007 Posts: 48 Location: London
|
Posted: Mon Jan 19, 2009 6:12 am Post subject: Force PAL using SDL |
|
|
I have 2 playstation 2 slim (a black and a pink one) they both PAL, but on the pink one, my homebrew using SDL make the console to switch ot NTSC signal...
How can I force the console to stay in PAL mode?
This is how I initialize the SDL:
| Code: | /* Initialize SDL */
if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
videoflags = SDL_SWSURFACE;
while( argc > 1 ) {
--argc;
if ( argv[argc] && !strcmp(argv[argc], "-fullscreen") ) {
videoflags |= SDL_FULLSCREEN;
} else {
fprintf(stderr, "Usage: %s [-fullscreen]\n", argv[0]);
exit(1);
}
}
/* Initialize the screen / window */
screenS = SDL_SetVideoMode(640, 480, 16, videoflags);
|
X _________________ softwares for artists on video game systems - http://www.pikilipita.com |
|
| Back to top |
|
 |
dlanor
Joined: 28 Oct 2004 Posts: 269 Location: Stockholm, Sweden
|
Posted: Mon Jan 19, 2009 10:43 pm Post subject: Re: Force PAL using SDL |
|
|
| kouky wrote: | I have 2 playstation 2 slim (a black and a pink one) they both PAL, but on the pink one, my homebrew using SDL make the console to switch ot NTSC signal...
| That is probably because the SDL libs use the same incorrect way of testing for video region as used by the old gsKit versions (as in: if(gsKit_detect_signal()==GS_MODE_PAL)). I think ragnarok2040 fixed that in his new gsKit updates, though I haven't checked it myself.
That old test method will work correctly only for the old fat PS2 consoles, but will cause all (I think) slim models to be misinterpreted as NTSC even for a PAL region.
This caused old versions of uLaunchELF to start with incorrect video mode on such consoles. But in recent versions of uLE this has been fixed by making a definitely correct test for the video region, by reading the "rom0:ROMVER" file from the bios rom of the console. The fifth character of that file indicates the video region in the same way as in some region dependent folder names, such that:
'E' == Europe == PAL
'U' == USA == NTSC/U
'I' == Japan == NTSC/J
| Quote: | How can I force the console to stay in PAL mode?
This is how I initialize the SDL:
| For SDL I'm not sure how best to work around it, but the definite fix should be to correct the bug inside the SDL implementation, thus eliminating the need for SDL-using applications to fix it on their own.
Best regards: dlanor |
|
| Back to top |
|
 |
kouky

Joined: 25 Sep 2007 Posts: 48 Location: London
|
Posted: Tue Jan 20, 2009 9:21 pm Post subject: |
|
|
Thanks for your lights. Unfortunately you don't seem to have a solution for me :(
I believe cosmito fixed that issue in the SDL Doom port:
| Quote: | | I also added the option to force a specific display mode (PAL or NTSC) for whom needs it - So just rename the DOOM.ELF to something ending with PAL or NTSC at the name (for example : DOOM_PAL.ELF or DOOM_NTSC.ELF). |
But I can't find the sources of his port and he didn't explained how he fixed it... _________________ softwares for artists on video game systems - http://www.pikilipita.com |
|
| Back to top |
|
 |
ragnarok2040
Joined: 09 Aug 2006 Posts: 230
|
Posted: Wed Jan 21, 2009 12:02 am Post subject: |
|
|
It looks like he uses a static int called force_signal. Setting it to 0 forces PAL and setting it to 1 forces it to NTSC.
To fix the problem in SDL itself, for use with older revisions of gsKit, the autodetection code needs changed to do what dlanor specified.
In sdl/src/video/ps2sdk/SDL_ps2video.c: | Code: | pal = (REG_VIDEO_MODE == MODE_PAL);
if (force_signal != -1)
{
/* 0 PAL, 1 NTSC */
pal = (force_signal == 0);
}
printf("SDL: initializing gsKit in %s mode\n", pal ? "PAL" : "NTSC");
gsGlobal = gsKit_init_global(pal ? GS_MODE_PAL : GS_MODE_NTSC); |
needs to be changed to something like: | Code: | int fd;
char romname[14];
fd = fioOpen("rom0:ROMVER", O_RDONLY);
fioRead(fd, &romname, 14);
fioClose(fd);
printf("SDL: initializing gsKit in %s mode\n", (romname[4] == 'E') ? "PAL" : "NTSC");
gsGlobal = gsKit_init_global((romname[4] == 'E') ? GS_MODE_PAL : GS_MODE_NTSC); | You'll need to add this to the top to avoid warnings about implicit declarations: | Code: | | #include <fileio.h> | To work with the newest version of gsKit, as dlanor suspected, all that region checking code wouldn't be needed as just calling gsKit_init_global() would setup an autodetected mode using the same method as above. Unfortunately, I'm not sure what else in SDL would need changing. From the looks of it, I don't think anything else is needed, but that's just my opinion from a cursory glance. For most apps that used the default interlaced field mode, it's usually just that call, since gsKit_init_global() doesn't take a mode parameter anymore.
A quick explanation of custom video modes using the newest revision of gsKit(in case you want to implement any in SDL itself):
Any display mode can be used by defining:gsGlobal->Mode
gsGlobal->Interlace
gsGlobal->Field
gsGlobal->Width
gsGlobal->Height
The Mode option takes any mode defined in gsInit.h.
The Interlace option takes GS_SETTING_ON for interlaced or GS_SETTING_OFF for non-interlaced.
Setting Interlace off halves the useable height.
The Field option takes GS_FRAME or GS_FIELD, where GS_FIELD uses full height and GS_FRAME uses half the height.
The Field option has no effect when Interlace is off.
The Width/Height dimensions are factors of the greatest common multiple(GCM) of the chosen display mode's width/height.
Calling gsKit_init_screen() after defining all of those fields will change the mode.
For example:GS_MODE_DTV_1080I has a max screen resolution of 1920x1080.
This means the GCM for width is 1920 and GCM for height is 1080.
That means draw buffer dimensions can be:640x540
960x540
1920x540
640x1080
960x1080
1920x1080 Smaller dimensions are probably possible.
Keep in mind that the larger dimensions won't leave enough vram for any normal usage.
Another example:
GS_MODE_NTSC and GS_MODE_PAL use a GCM of 2560 for width.
These are the only modes that use such a large GCM.
This is to support multiple widths of 256, 320, 384, 512, 640.
NTSC's GCM for height is 448 and PAL's GCM for height is 512.
Now you have a choice of at least 10 different combinations from 256x224 to 640x448 in NTSC and 256x256 to 640x512 in PAL.
Remember that heights of 224 or 256 need to be used for non-interlaced mode or interlaced GS_FRAME mode.
Probably a bit of information overload, but anyone interested in changing the SDL video implementation can use this as a reference. |
|
| Back to top |
|
 |
kouky

Joined: 25 Sep 2007 Posts: 48 Location: London
|
Posted: Wed Jan 21, 2009 7:06 am Post subject: |
|
|
I downloaded the latest version of gskit from the svn.
I compiled and installed the gsKit lib
I downloaded the latest version of SDL from the svn.
on the file sdl/src/video/ps2sdk/SDL_ps2video.c,
I replaced the region checking system code by just:
| Code: | | gsGlobal = gsKit_init_global(); |
I compiled and installed the SDL lib.
And now my pink slim PS2 is detected as a PAL one, which is correct :)
Thanks a lot Dlanor and Ragnarok2040 for your explanations, they were really helpfull. _________________ softwares for artists on video game systems - http://www.pikilipita.com |
|
| Back to top |
|
 |
cosmito
Joined: 04 Mar 2007 Posts: 314 Location: Portugal
|
Posted: Wed Jan 21, 2009 9:55 am Post subject: |
|
|
| kouky wrote: | Thanks for your lights. Unfortunately you don't seem to have a solution for me :(
I believe cosmito fixed that issue in the SDL Doom port:
| Quote: | | I also added the option to force a specific display mode (PAL or NTSC) for whom needs it - So just rename the DOOM.ELF to something ending with PAL or NTSC at the name (for example : DOOM_PAL.ELF or DOOM_NTSC.ELF). |
But I can't find the sources of his port and he didn't explained how he fixed it... |
(already typed at the other thread, but for the others that might being reading this :
here's the sources of the two ports i'm experimenting with:
http://svn2.assembla.com/svn/pedroduarteps2dev_public/lsdldoom_PS2/
http://svn2.assembla.com/svn/pedroduarteps2dev_public/ps2doom-src/ |
|
| Back to top |
|
 |
|
|
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 vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|