kounch
Still Fresh
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!:
	
		
	
	
	
		
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()
				
			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)); 
        }
  }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()
 
	
 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		