Automatic video mode switching when loading game

  • hi,

    i allways seem to get the odd game or prog that won't run at all, or won't run properly in pal-50 mode.
    to make them work properly i need to switch the xbox to pal-60, which on my tv squashes the picture and deforms the top and bottom, or rarely ntsc, which on my tv plays squashed and in black and white.
    would it be possible to set individually (in a default.txt file even) to switch outputs on program launch, and then revert back when xbmc opens again (which would be after a cold or warm reboot)?

    so when i boot xbmc it stays in pal-50 mode, but if i boot say, hitman contracts ntsc (which doesn't work in pal-50 mode) then xbmc will automatically switch to pal-60 just before launching the game. this would take slightly longer to launch i think, however it's much easier than going into the ms dash everytime i want to play hitman. for other games which haven't been set to change, it would be the same loading time.

    is this possible?
    thanks
    morien


  • I've fixed the code a bit - it might be worth putting something like as a setting for people that swap between PAL and 480p etc.

    Changes made in Application.cpp

    Below the line g_graphicsContext.SetGUIResolution(initialResoluti on);


    // See if we can go to 480p - RH
    BYTE currentCableMode = 0;
    HalReadSMBusValue(XKUtils::SMBDEV_PIC16L, XKUtils::PIC16L_CMD_AV_PACK, 0, (LPBYTE)¤tCableMode);

    if((currentCableMode == XKUtils::AV_PACK_HDTV) && XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
    {
    // We're in PAL mode, but connected to HDTV so switch to NTSC for 480p
    F_VIDEO ForceVideo = VIDEO_NTSCM;
    F_COUNTRY ForceCountry = COUNTRY_USA;
    char temp[1024];

    helper.GetXbePath(temp);

    char temp2[1024];
    char temp3[2];
    temp3[0] = temp[0]; temp3[1] = '';
    helper.GetPartition((LPCSTR)temp3,temp2);
    CStdString strTemp(temp+2);
    int iLastSlash = strTemp.rfind('\');
    strcat(temp2,strTemp.substr(0,iLastSlash).c_str()) ;

    Destroy();
    CUtil::LaunchXbe(temp2,("D:\"+strTemp.substr(iLastSlash+1)).c_str(),NULL,ForceV ideo,ForceCountry);
    }



    Following code

    else if ((DWVideo == XKEEPROM::VIDEO_STANDARD::PAL_I) && ((XGetVideoStandard() == XC_VIDEO_STANDARD_NTSC_M) (XGetVideoStandard() == XC_VIDEO_STANDARD_NTSC_J) initialResolution < 6))
    {
    CLog::Log(LOGINFO, "Rebooting to change resolution from %s back to PAL_I", (XGetVideoStandard() == XC_VIDEO_STANDARD_NTSC_M) ? "NTSC_M" : "NTSC_J");
    ForceVideo = VIDEO_PAL50;
    ForceCountry = COUNTRY_EUR;
    bNeedReboot = true;
    fDoPatchTest = true;
    }


    changed to


    else if ((DWVideo == XKEEPROM::VIDEO_STANDARD::PAL_I) && ((XGetVideoStandard() == XC_VIDEO_STANDARD_NTSC_M) (XGetVideoStandard() == XC_VIDEO_STANDARD_NTSC_J) initialResolution < 6))
    {
    // See if we can go to 480p - RH
    BYTE currentCableMode = 0;
    HalReadSMBusValue(XKUtils::SMBDEV_PIC16L, XKUtils::PIC16L_CMD_AV_PACK, 0, (LPBYTE)¤tCableMode);

    if(currentCableMode == XKUtils::AV_PACK_HDTV)
    {
    // Do nothing
    bNeedReboot = false;
    fDoPatchTest = false;

    }
    else
    {
    CLog::Log(LOGINFO, "Rebooting to change resolution from %s back to PAL_I", (XGetVideoStandard() == XC_VIDEO_STANDARD_NTSC_M) ? "NTSC_M" : "NTSC_J");
    ForceVideo = VIDEO_PAL50;
    ForceCountry = COUNTRY_EUR;
    bNeedReboot = true;
    fDoPatchTest = true;
    }
    }


  • actually it would work just fine with the current code. however, upon launching xbmc it restores the eeprom saved video mode (for obvious reasons - just because you wanted to play a game in a particular video mode, you of course want it to reset when you return). so if you want this, a start would be removing the restore code on application load.


  • uhm,

    perhaps i accidentially uploaded the wrong version. will check it out this evening, i was might tired yesterday

    spiff

    edit: had a look at the uploaded code. everything looks correct from here. are you sure that you added all necessary files to the project? perhaps a clean is required. no bool cutil::launchxbe(...) exists in the cvs tree anyway, it's a void function.

    will try to apply it to a vanilla cvs tree when i get back home


  • okay,

    i figure that this means that i should alter the patch to ignore pal60 settings and launch pal games in pal.

    unless someone shouts, i'll upload a new version soon. also, i'll add a parameter to force which mode to launch in, if somebody decides to add it to the context menu (i could always add it, however it should be stored in the db which i think should be done by somebody with the experience..)

    edit: done

    spiff


  • well sure the xbe's might run at 60hz, but all video media will be jerky as hell. i, as in me, won't add this for sure.


  • sf.net patch #1194146

    all cred/blame to cherry for sharing his code :)

    spiff


  • no.

    i designed it like it is because that's the way i like it... you are of course welcome to do alterations to the source code.

    and may i ask: why would you like it to work that way?


  • Looks like a good idea.

    Bizarely, the code I posted worked fine on Saturday, then failed to work on Sunday - it just constantly rebooted XBMC, suggesting that the NTSC shadow copy patch thing hadn't worked.

    I'll try to get my code working reliably, then take a look at making it configurable. I like the idea of a config file, but I don't think it's possible to detect if digital audio is present - anyone confirm this??

    loading XBMC twice is actually much quicker than you'd expect, and not really noticable.. I suspect XBMC spends most of it's time loading the graphics and other DLLs - my patch was run before all this was done.


  • @filinc:

    why do you need to switch back to pal for pal framerate films? i'm running it in ntsc at 720p and find it plays pal movies without any artifacts of any kind.


  • why would u like to run a pal game in ntsc when you can run it in pal, the res it was designed for?
    60fps instead 50fps, 20% faster

    then runs like us/jap version speedwise


  • first of all, i won't go near this, since i have no 1.6 and no hd ;)

    but i'll tell you that it should be doable. you could use the same trick that we use to setup the game region, that is patching the in-memory eeprom copy.
    should just be a matter of adjusting the offsets.


  • i've got the videomode switch source code from cherry (link) (http://www.xboxmediacenter.com/downloads/source/xbox/videomode.zip) that unleashx uses to switch pal <=> ntsc 'on-the-fly' when/before launching a game if someone would like to look at it. this code does not write to eeprom (however it do require a restart of a xbe so can't be used to switch video modes within xbmc), i believe it does this by patching the xbox bios (or eeprom?) that gets loaded into the protected memory are in the ram at boot(?). ps! i believe nexgen also have source code available for this(?), evox and avalauch also have this fucntion but i believe they do it in a other way(?).

    maybe an unofficial dev could code a patch for this from that?, (as i don't think any devs on team-xbmc prioritise this?)


  • posting this here (and will cleanup the 'other' incorrect thread)

    i got a pal xbox and when i run a ntsc games it now cherry switches it to ntsc. but when i igr and my dash (xbmc) restarts, my xbox is now in ntsc mode. it would be nice if xbmc could detect and change back to pal (as pal is my preferred choice for ui, higher resolution)

    a600 said:

    i also have a pal xbox but don't have that problem. when i igr after playing a ntsc game, xbmc is set, as always, to pal60.


  • just for the record, do i get this right.
    the autoregion option do not write to the eeprom, instead the copy in the ram is patched?
    so i'm at no risk render my eeprom useless if sh.t happens.

    kk


  • compiled fine here. although i've yet to actually try it out (wife's watching tv).


  • i hope you realize that still no info is saved. but atleast you can manually change the region now.. and xbe header values will be correctly used..


  • i used to put my xbox in ntsc because most of my games require to if they want to function properly. but because there was this option (switch to correct video mode based on game region) i put my xbox into pal, because xbmc is much more sharper en detailed... nonetheless, if i run a game, let's say sh4 (from hdd) i notice that the video region has not been changed, am i doing something wrong?


  • failing that, a force 50hz option would be good also, as there's some emulators that need to be run in 50hz and would again save switching the console manually


  • ms dash doesn't have an option of starting a game in pal60 - there's only 2 choices: pal or ntsc.

    if you have pal60 enabled in the ms dash, then it is up to the game to choose to use it (or give you the option of using it).

    there is a "forced-pal60" mode, but it is unavailable in the ms dash, and is not documented at all in the xdk docs. this hasn't stopped modchip makers + software writers employing it, however. basically it is equivalent to running in ntsc as far as resolutions + timings go.

    cheers,
    jonathan


  • spiff has done an excellent in the cvs with his country patch switching. but i have noticed that when you insert a dvd-rom game it's not added to the programs database like music/videos are. if this could be coded to do so it would mean that dvd-rom's would also switch regions upon launch.

    and a pretty please... :) as at the moment the only way is to transfer the dvd to harddisk and run that way. (very long winded) and i don't like eprom switching to much with enigmah.

    thank you guy if you can take a look. and thank again spiff for the help with my bios.


  • Basically, each time xbmc starts, it check to see if the HD component lead is connected (or in my case, the switch on the HD / Scart box) and if so, quits and re-runs itself in NTSChmm, I'm not a programmer myself but I still think it would be better to put the function into a separate XBE, like Team-XBMC's shortcut tool (http://www.xboxmediacenter.com/wiki/index.php?title=As_a_Dashboard#Option_1_-_Using_the_Team_XBMC_Shortcut.xbe_.28Recommended.2 9). That way you would not have to load the XBMC XBE twice, the XBMC XBE is much larger and thus takes much longer to load. I do however like the idea of the cable auto-detect feature you implemented.

    How about this instead? Add on-the-fly video-mode switching of the EEPROM shadow-copy in RAM before launching a specific XBE to the Team-XBMC's shortcut tool (http://www.xboxmediacenter.com/wiki/index.php?title=As_a_Dashboard#Option_1_-_Using_the_Team_XBMC_Shortcut.xbe_.28Recommended.2 9), with the option of cable auto-detect (for both video and audio), configurable via a .cfg file (or xml). Maybe also add GetXbePath to is and make is pass that information along as a parameter to XBMC so if an option to edit that .cfg file (or xml) from XBMC's GUI was implemented then XBMC would automaticly know where that XBE and it's matching cfg file (or xml) is located. That XBE program would still be small and fast to load, and there would be no need to ever load the same XBE twice. The audio option would be nice if like myself use digital-audio when in NTSC-mode (connected to a Xbox HD cable-adapter and HDTV display-device) and analog-audio when in PAL mode (connected to a standard definition Xbox composite video cable and analog stereo to CRT TV built-in speakers).

    Suggested .cfg file (or xml) example:


    E:AppsXBMCdefault.xbe





    true

    true

    digital

    true

    false

    stereo

    analog

    false

    false

    mono

    PS! Note that all this should only touch the EEPROM shadow-copy in RAM and never write to the EEPROM!
    The EEPROM it's only capable of aprox. 1000 erase/write cycles so will get damaged if write to it too often.


  • some hdtv users may be aware as i am how annoying ms was on their design's of v1.6 xbox's and that awful xcalibur chipset. some games like panzer dragoon and jet set radio future will not work properly in 480p mode, and, come to think of it, neither will some emulators.

    i was wondering if it was possible to do something in xbmc where i can set up games (or emulators) to only run in 480i mode while the rest can still run in 480p without having to constantly switch these in my mod's bios. (somehow stop the games xbe from seeing that 480p is an option for it to run?) that would be an awesome feature, i think, for 1.6 hdtv xbmc users, though i realize that the number of us may be quite small and this wouldn't exactly be a priority. ;)


  • fixed in cvs


  • after much conversation on irc (many thanks for your time jonathan), it appears that the xbox is continuously soft reseting (possibly between ntsc_m and ntsc_j). this looks like potentially a bios problem. i'll update the bios over the next week or so and re-post if this solves things.

    does anyone else with an ntsc box (particularly japanese) have a similar problem?


  • added


  • Is there anyway to force XBMC to enable the 480p mode without putting the xbox in to NTSC?No

    So I'm after some way of getting XBMC to boot & play video in 480p, but games to work in PAL50 / PAL60. Any ideas?Not currently possible with XBMC, (or any other Xbox software for that matter).

    In believe that in theory it should be possible to enhance the Video Mode Switching code for My Programs, if combined cherry's videomode code with nkpatcher to patch a EEPROM shadow copy in RAM when starting a game, ...I think?

    Problem is finding a skilled programmer/developer with the time and inerest to take on a such project :sniffle:


  • please can we add an auto-force switch for all pal games in 60hz, as about 50% run in pal50, not all in pal60.

    currently the only way is to keep switching back and forth in enigma.

    and no its not a good solution to leave the console always in ntsc, as then one has to keep switching back for pal framerate movies

    i would think this a comparatively simple thing to add, as there is already a switch to force already 60hz games in ntsc or pal60.


  • this is what i mean! unbelievable speed and a very talented coder. spiff i owe you many thanks yet again.

    if fact i owe the entire xbmc team a huge thank for the great media center your have created amongst yourselves.

    thank guys. :thumbsup:


  • Is there anyway to force XBMC to enable the 480p mode without putting the xbox in to NTSC??

    I have a projector hooked up via component, and a standard PAL TV via composite, with a box off ebay that switches between the two.

    I can put the xbox into NTSC and get the 480p mode working ok, but the TV can't handle the NTSC signal and goes into black and white.

    So I'm after some way of getting XBMC to boot & play video in 480p, but games to work in PAL50 / PAL60.

    Any ideas????


  • i had to add cherrypatch.cpp to the xbmc project and compiled fine.

    edit: i just tried it and seems to work very well but i think it also should be added to the context menu to choose between ntsc, pal50 and pal60 modes because some games, for example pal version of halo, are very choppy with pal60.


  • @filinc:

    why do you need to switch back to pal for pal framerate films? i'm running it in ntsc at 720p and find it plays pal movies without any artifacts of any kind.
    runs jerky

    pal = 25fps
    ntsc = 23.3 or 29.9fps

    pal50 and pal60 autoswitching (which is already in the program) resolves this perfectly, so no manual switching neccesary


  • well sure the xbe's might run at 60hz, but all video media will be jerky as hell. i, as in me, won't add this for sure.
    dont really see the big issue adding this feature, as its a comparitively easy thing to add considering the complexity of xbmc

    i have never had a pal game with video run jerky in ntsc, with 100s of games i have run, there just isnt the issue you mention

    adding this feature is a neccesity, and there's no logical evidence not to have it

    most games are meant for 60hz ntsc and only converted to pal later for european users


  • please do. you can also contact me via #xbmc on efnet, as i'll need help sorting this out.

    cheers,
    jonathan


  • this feature would certainly be great :)

    i did look for a xbe to changed it and then load the original renamed xbe, but never found it :(

    hope some one can implement this :thumbsup:


  • great will this be implanted in later builds of xbmc or must i do it myself??


  • i believe that ava launch can handle doing this. a work around would be to set up ava launch and use that to launch your games. (you can launch ava from xbmc if you don't want to use it as a dash.)


  • no i have my console in pal60 which means when i play pal movies of 25fps then plays them, and when wants to play ntsc movies of 29.999fps then it switches itself to pal60.

    if you put my console in ntsc i dont get this benefit

    a simple 'force 50hz games in 60hz' and visa versa would fix this, as my post already explained


  • there is. disable autoswitching. eureka.

    if you want to run your games pal games in ntsc, and your ntsc games in ntsc (obviously), you don't need any switching.

    unless there's something i haven't thought of?

    and there's always manual override.


  • hi,

    i actually wondered why cherry's code enabled pal60. i'd reckon that the switch from pal->pal60 would be something handled by the game.

    do anybody know the behaviour of the msdash? mine is non-startable (damn starwars dvd's) and i don't feel like fixing it today..


  • no i have my console in pal60 which means when i play pal movies of 25fps then plays them, and when wants to play ntsc movies of 29.999fps then it switches itself to pal60.
    xbmc already does that if you in the video-settings selected "enable pal60", there are also options for:
    "play ntsc videos at pal rates"
    "play pal videos at ntsc rates"
    "play ntsc videos in pal60"

    ps! don't compare/confuse videos with games, it's not the same on the xbox; it is not possible to switch between ntsc and pal for videos like you can for games, you can only switch between pal(50) and pal60 on a pal box without using a third-party application like enigmah-video-switch (or avalaunch) to switch between pal and ntsc in the eeprom (which do require a restart or the xbe).


  • most likely the game is (wrongly) set to 'mixed region' in the .xbe

    lots of those around and nothing 'automatic' to do about it. i have been plundering adding 'launch in pal' 'launch in ntsc' to a contextmenu in xbmc, but haven't gotten around to it yet..


  • hi,

    this is my first post here. because there is only one option i am missing in xbmc.

    i know that i can change the region setting for games to start with the default region. this is great so far. but would it be possible to do this only for specific games???

    like i start all my games with the dash-default region when i hit the "a" button. when using the "white" button (or any else) a menu could pop asking asking for starting the game in it's own default region (like the switch i can enable in the settings). would something like that be possible?! it doesn't need to be stored or anything else... just for the game i just started.

    if any more explenation is needed just ask!

    thx for your patience!


  • hi,

    i'm probably responsible for this mess :) i never had a ntsc-j box to test with.. will have a look at the src now


  • I'm not too bothered about games, more interested in video / dvd playback etc. It's usually my son playing games, and I'd rather he doesn't use all the life in the projector bulb!

    I'm not that up on the internals of the xbox, but am a software & hardware developer so know a fair bit about video etc..

    Can xbmc not just bash some new values into the video hardware registers to enable different video modes??

    If so, does anyone have any idea how to do this - I might be up for downloading the xbmc source (and xdk) and seeing if I can tweak it.


  • hmm. well i guess i'll do that until a time when it's implemented into xbmc... if ever.. thanks for the heads up.

    morien


  • there's an option for auto switching games, and forcing 60hz games in pal60 or ntsc, but also needed is an option for autoswitching 50hz games into pal60/ntsc and visa versa


  • setting "auto switch video mode based on game region" to "on" and then rebooting results in my xbox hanging on the "x" splash logo of the bios boot screen.

    setting the "auto switch ...." to "off" and then rebooting works fine.

    deleting the contents of the 0face008 folders under tdata and udata fixes the problem (until the next time "auto switch...." is selected).

    xbmc is running as dashboard. i've been using xbmc as dashboard for around 6 months with little problem. everything is in its standard location (.xbe and xboxmediacenter.xml on c:, everything else in e:/apps/xbmc/ and "home" tag set accordingly). as i said, everything's fine if the "auto switch based on game region" flag isn't set.

    have tried about 4 different recent versions of xmbc including the 07-15 cvs, 06-04 pimped and 05-30. all installs have been as clean as possible (deleted e:/cache, x:, y:, z:, 0face008 folders and all of e:/apps/xbmc). the only edit to the xboxmediacenter.xml has been to set the "home" location to e:/apps/xbmc/.

    system details:
    ntsc (japan) system
    xecuter x2 4977 bios
    matrix modchip

    any thoughts would be appreciated. have a feeling it's related to the xbox being ntsc.

    i can post the contents of 0face008 folders, xboxmediacenter.xml and xbmc.log if they would help.

    many thanks for all the hard work on xbmc.


  • hi,

    this is my first post here. because there is only one option i am missing in xbmc.

    i know that i can change the region setting for games to start with the default region. this is great so far. but would it be possible to do this only for specific games???

    like i start all my games with the dash-default region when i hit the "a" button. when using the "white" button (or any else) a menu could pop asking asking for starting the game in it's own default region (like the switch i can enable in the settings). would something like that be possible?! it doesn't need to be stored or anything else... just for the game i just started.

    if any more explenation is needed just ask!

    thx for your patience!
    sorb, i don't fully understand what you are trying to do. when you use the override menu(pressing the white button on a specific game), your launch setting is remembered and if you need to know the default video mode, just select "launch in" and it will tell you the default.


  • i tried to compile but it gives the following error:

    util.obj : error lnk2019: unresolved external symbol "bool cdecl cutil::launchxbe(char *,char *,char *)" (?launchxbe@cutil@@saxpad00@z)


  • yes you are correct


  • Can xbmc not just bash some new values into the video hardware registers to enable different video modes?Not without restarting the xbe (Xbox executable) or loading a other xbe, and the Xbox can only run one executable/process at a time. You can read this topic thread (http://xbmc.org/forum/showthread.php?p=121181) and this other topic thread (http://xbmc.org/forum/showthread.php?t=2926) for more detailed explainations and some solution ideas and workaround suggestions. The XBMC source code is also of course a good source of information.

    Maybe you could 'just' create a small xbe program with a matching .cfg file (or xml) which only quickly preforms video-mode switching on the EEPROM in RAM before launching a specific xbe, ...so kind of like how Team-XBMC's shortcut tool (http://www.xboxmediacenter.com/wiki/index.php?title=As_a_Dashboard#Option_1_-_Using_the_Team_XBMC_Shortcut.xbe_.28Recommended.2 9) (source code available in the SVN (https://svn.sourceforge.net/svnroot/xbmc/trunk/XBMC/tools/ShortcutXBE/)) works but with the addition of on-the-fly video-mode switching. That way you could use that xbe to launch XBMC each time, and maybe even add an option to edit that cfg (or xml) file from XBMC settings in the GUI. (The source code from nkpatcher (http://www.xbox-scene.com/xbox1data/sep/EEpFAZZyFAlOzQiFJa.php) and/or cherry's videomode code could possible be of help, more information here (http://xguides.xbox-scene.com/tikiwiki/tiki-index.php?page=nkpatcher10))
    E:AppsXBMCdefault.xbe
    ntsc
    720p


  • Right - I've sorted my problem...

    Xbox is put in to NTSC, and 480p enabled. Xbox then put back to PAL.

    Following blunder code added to CApplication::Create, just after the GetModes() command:

    // See if we can go to 480p - RH
    BYTE currentCableMode = 0;
    HalReadSMBusValue(0x20, 0x4, 0, (LPBYTE)¤tCableMode);

    if((currentCableMode == 1)/*AV_PACK_HDTV*/ && g_videoConfig.HasPAL())
    {
    // We're in PAL mode, but connected to HDTV so switch to NTSC for 480p
    char temp[1024];
    helper.GetXbePath(temp);
    char temp2[1024];
    char temp3[2];
    temp3[0] = temp[0]; temp3[1] = '';
    helper.GetPartition((LPCSTR)temp3,temp2);
    CStdString strTemp(temp+2);
    int iLastSlash = strTemp.rfind('\');
    strcat(temp2,strTemp.substr(0,iLastSlash).c_str()) ;
    Destroy();
    CUtil::LaunchXbe(temp2,("D:\"+strTemp.substr(iLastSlash+1)).c_str(),NULL,VIDEO_ NTSCM,COUNTRY_USA);

    }

    Basically, each time xbmc starts, it check to see if the HD component lead is connected (or in my case, the switch on the HD / Scart box) and if so, quits and re-runs itself in NTSC.

    Must admit that XBMC looks a lot better in 480p (my projectors native resolution) than normal PAL.

    Big thanks to the XBMC guys for making the thing compile 1st first time, and actually documenting the code :)


  • why would u like to run a pal game in ntsc when you can run it in pal, the res it was designed for?


  • auto switch to ntsc(only games that only run under ntsc) when i start a game.

    i like to have this because some of my games only run under ntsc..like psychonauts (i must run video disc switch and switch to ntsc for this game to work)

    my xbox is pal







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Automatic video mode switching when loading game , Please add it free.
    Posted by mike under xn--6kr096akncb2j.com
    edit