GP2X Adding Tv-out Support To Your Software


kounch

Still Fresh
Joined
Dec 20, 2005
Messages
84
Website
Visit site
Hi
as a consecuence of the research i have done for my entry to the GP2X 2006 competition, i think i have all the clues to correctly enable GP2X software to work with TV-Out support.

I have updated the Wiki with the info, here: http://wiki.gp2x.org/wiki/TV-out_support

I have also studied the changes you have to make to Rlyeh's minilib. In fact, it is enough to change only two functions!:
Code:
void gp2x_video_RGB_setscaling(int W, int H)
{
  float escalaw,escalah;
  int bpp=(gp2x_memregs[0x28DA>>1]>>9)&0x3;

  if(gp2x_memregs[0x2800>>1]&0x100) //TV-Out
  {
    escalaw=489.0; //RGB Horiz TV (PAL, NTSC)
    if (gp2x_memregs[0x2818>>1]  == 287) //PAL
      escalah=274.0; //RGB Vert TV PAL
    else if (gp2x_memregs[0x2818>>1]  == 239) //NTSC
      escalah=331.0; //RGB Vert TV NTSC
  }
  else //LCD
  {
    escalaw=1024.0; //RGB Horiz LCD
    escalah=320.0; //RGB Vert LCD
  }

  // scale horizontal
  gp2x_memregs[0x2906>>1]=(unsigned short)((float)escalaw *(W/320.0));
  // scale vertical
  gp2x_memregl[0x2908>>2]=(unsigned long)((float)escalah *bpp *(H/240.0)); 
}
Code:
void gp2x_video_RGB_setwindows(int window0, int window1, int window2, int window3, int x, int y)
{
  int window,mode,mode2,x1,y1,x2,y2;
  int xmax,ymax;
  
  if(gp2x_memregs[0x2800>>1]&0x100) //TV-Out
  {
    xmax=669;
    if (gp2x_memregs[0x2818>>1]  == 287) //PAL
      ymax=279; //TV-Out PAL
    else if (gp2x_memregs[0x2818>>1]  == 239) //NTSC
      ymax=231; //TV-Out NTSC
  }
  else //LCD
  {
  xmax=319;
  ymax=239;
  }
  
  x=(x * xmax) / 319;
  y=(y * ymax) / 239;

  //enable all RGB windows
  gp2x_memregs[0x2880>>1]|=(1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2);

  for(window=0;window<4;window++) //windows 0..3
  {
   if(window==0) x1=0, y1=0, x2=x,    y2=y,    mode=window0;
   if(window==1) x1=x, y1=0, x2=xmax, y2=y,    mode=window1;
   if(window==2) x1=0, y1=y, x2=x,    y2=ymax, mode=window2;
   if(window==3) x1=x, y1=y, x2=xmax, y2=ymax, mode=window3;

   if(mode<0) { gp2x_memregs[0x28da>>1]&=~(1<<(window<<1)); }
   else {
          mode2=(mode>0x0F?0xF:mode);

          //set alpha 0..0xE / colorkey,solid 0xF value
          if(window<3)
          {
           gp2x_memregs[0x28de>>1]&=~(mode2<<(window<<2)); 
           gp2x_memregs[0x28de>>1]|= (mode2<<(window<<2));
          }
          else
          {
           gp2x_memregs[0x28e0>>1]&=~(mode2<<((window-3)<<2)); 
           gp2x_memregs[0x28e0>>1]|= (mode2<<((window-3)<<2)); 
          }

          //set window as blended (2), transparent/colorkey (1), solid (0)          
          gp2x_memregs[0x28dc>>1]&=~(3                                      <<(window<<1));   
          gp2x_memregs[0x28dc>>1]|= ((mode==0x11 ? 0 : (mode==0x10 ? 1 : 2))<<(window<<1)); 
          
          //window coordinates
          gp2x_memregs[(0x28e2+window*8)>>1]=x1;     
          gp2x_memregs[(0x28e4+window*8)>>1]=x2;
          gp2x_memregs[(0x28e6+window*8)>>1]=y1;
          gp2x_memregs[(0x28e8+window*8)>>1]=y2;

          //enable window
          gp2x_memregs[0x28da>>1]|=(3<<(window<<1)); 
        }
  }
I have applied this changes to the code of minilib in GP2XSpectrum, GP2XEngine and Selector source code, and found that they work perfectly with TV-Out now.

EDIT:This code only works with minimal lib 0.B and if you don't change the default value of MLC_STL_HW (C000 290C) register, set by gp2x_init()
 
Vimacs posted on Feb 21 2006 at 01:12 PM said:
would be of help if the comments wouldnt be in some wierdo language.
I am sorry if my native language is one that you don't like. :unsure:
If you want to know how it works, please check the wiki link.
If you want to make it work with a program using Rlyeh's minilib, just change the code of the two functions in the file minilib.c and recompile. You don't need then to understand the comments. ;)
 
Last edited by a moderator:
Its not about likeing, its about understanding :)
Keep in mind that comments in "insert native non english language" arent understandable by most others.
 
Vimacs posted on Feb 21 2006 at 12:12 PM said:
would be of help if the comments wouldnt be in some wierdo language.
I'm sure what you meant to say was "thanks" and you just accidentally typed something that makes you sound like a complete asshole.

Way to respect the diversity of these boards and shower thanks on those who do good work to make our consoles do cool stuff. :(

And that "wierdo language" appears to my untrained eye to be spanish (though it could be portuguese) so it's not so uncommon. I'm sure you can get someone / google to make sense of it for you.

@ kounch: gracias.


edit: hmmm... server didn't respond for a while when I tried to post this. When I wrote it vimacs had only posted once.
 
Last edited by a moderator:
Vimacs posted on Feb 21 2006 at 01:26 PM said:
Its not about likeing, its about understanding :)
Keep in mind that comments in "insert native non english language" arent understandable by most others.
I am sorry if i annoyed you. I have removed all "wierdo" language from the post. I hope that it's better for you now.
Regards
 
Last edited by a moderator:
i saw this thread when it was posted, i was going to say "nice work" or whatever but figured i'd let someone who would actually use the code soon say something...i check back and yeeeouch

so anyway, nice work kounch.
 
I would like to note that

foreign language comments >>>>>> no comments

Vimacs: at least he was nice enough to add them.
 
Good work kounch :)

However, I think vimacs should be apologizing, not you, as he seemed a little harsh. We value your experise, even if the comments are not in the boards normal language (after all, there are plenty of online translators around should we wish to understand them).
 
Thanks for your research, Kounch.

And...
Vimacs posted on Feb 21 2006 at 01:12 PM said:
would be of help if the comments wouldnt be in some wierdo language.
Is it hard to understand that not every coder in the world wants or can write all comments in English? Yes, I know writting them in English would make it accessible to more people but come on, there are plenty of translators out there. Is it that hard?

Besides, and answering in a similar way you did, I'm not an English speaker, but doesn't that "wierdo" word sound a bit weird?
 
Last edited by a moderator:
??? My screen keeps zooming in every N seconds, where N is the refresh rate I set >_<! I have FX2.0.0 ... is that why I'm having issues w/tv out patch?
 
I've always calculated the verticale scale by Ratio * HorizPitch which is what is stated in the manual (okay I know the manual isn't always 100% accurate). It's always looked to give the right results - however I've not done extensive testing, and it's been months since I last touched that part of the code.
Just to note, when using the menu to go into TV-Out it outputs the whole screen for both odd and even fields rather than alternate lines. This produces better results for non-interlaced low-res sources like 320x240p but doesn't work for native TV resolutions 720x480i or 720x576i

Whoa, is something wrong with my GP2X or have GPH messed up TV support in fw2.0? I'm getting a shakey picture and after a few presses of the joystick on the menu I loose the picture totally. This never happened before
 
PokeParadox posted on May 23 2006 at 10:11 PM said:
If you use NTSC mode for TV out, you have to be quick to get to the program that you want to run on TV out. Unfortunately the Tv out fixer doesn't like the menu in NTSC mode.
Hi
i have just found that the TV-Out Fixer version on gp2x archives is not the latest. A few days after the coding competition i released a new version (v0.3b2) which i thought that fixed the problem with GP2X main menu and NTSC. You can download it from GP32Spain (http://gp32spain.com/foros/downloads.php?do=file&id=479) or, if there is any place that i can upload it, you can tell me so.
If this version does not fix the NTSC problem for you, please contact me via PM, and i will try again to fix it for the main GP2X Menu on NTSC mode.

Regards

kounch
 
Last edited by a moderator:
Vimacs posted on Feb 21 2006 at 12:12 PM said:
would be of help if the comments wouldnt be in some wierdo language.

I do hope those wierdo countries do not sing their national anthems in some "wierdo language" and upset our german friend at the world cup!!
 
Last edited by a moderator:
Hi Kounch,

Any news of being able to set TV-Out from within your program? I still need to do this...
A tool to set tv-mode, run an application and exit would be awesome...

Marton
 
kounch posted on May 26 2006 at 10:24 AM said:
PokeParadox posted on May 23 2006 at 10:11 PM said:
If you use NTSC mode for TV out, you have to be quick to get to the program that you want to run on TV out. Unfortunately the Tv out fixer doesn't like the menu in NTSC mode.
Hi
i have just found that the TV-Out Fixer version on gp2x archives is not the latest. A few days after the coding competition i released a new version (v0.3b2) which i thought that fixed the problem with GP2X main menu and NTSC. You can download it from GP32Spain (http://gp32spain.com/foros/downloads.php?do=file&id=479) or, if there is any place that i can upload it, you can tell me so.
If this version does not fix the NTSC problem for you, please contact me via PM, and i will try again to fix it for the main GP2X Menu on NTSC mode.

Regards

kounch
I'm not able to downloadfrom gp32spain. It needs registration I think but cant read spanish so cant do that.
 
Last edited by a moderator:
Back
Top