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: Select all
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: Select all
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:
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.