TV-out support

From wiki.gp2x.org

If the display of an application through TV-out is squashed/stretched/only takes up part of the screen, one way of fixing it seems to be through the scale factor registers.

The factor scale is defined using a scale of 320x240, so , for example, a screen with size 160x80, would have a horizontal scale ratio of 0.5 and and a vertical scale ratio of 0.33.

Contents

0xC000 2906: horizontal scale factor

This register is the horizontal scaling ratio multiplied by 1024 if using LCD, so if the screen is only taking up half the display horizontally then:

gp2x_memregs[0x2906>>1]=512;

will stretch the image to fill the whole screen.

Else it is the horizontal scaling ratio multiplied by 489 if using TV-Out

For the previous example (screen 160 pixels width, horizontal scale ratio of 0.5), with TV-Out enabled:

gp2x_memregs[0x2906>>1]=244; //Result of 0.5*489

will stretch the image to fill the whole screen.

0xC000 2908: vertical scale factor

This register is the vertical scaling ratio multiplied by

  • 1 if using 8bit colour or 2 if using 16bit colour
  • 320 if using LCD, 274 if using TV PAL or 331 if using TV NTSC

For the previous example (screen 80 pixels height, vertical scale ratio of 0.33), 8bit colour, with TV-Out enabled in PAL Mode:

gp2x_memregs[0x2908>>2]=93; //Result of 0.33*1*279

0xC000 290C : RGB Width

This register is the screen size multiplied by 1 if using 8bits colour, or 2 if using 16 bits colour.

For the previous example (screen 160 pixels width, horizontal scale ratio of 0.5):

gp2x_memregs[0x290C>>1]=160; //Result of 1*160

0xC000 0x28E2 and following : RGB Windows

You must also make sure that the RGB Windows (defined using registers from 0xC000 0x28E2 and varying depending uppon the number of windows), have enough size tho keep the whole screen. The RGB Window max width es 329 for LCD or 669 for TV-Out, the RGB Window max height is 239 for LCD, 279 for TV-Out PAL or 231 for TV-Out NTSC.

How to tell if TV-out is enabled

Bit 8 of 0xc000 2800 controls LCD/TV:

       if(gp2x_memregs[0x2800>>1]&0x100) {
               // set up display for tv out
       } else {
               // set up display for lcd
       }

MLC_DPC_X_MAX (0xc002 2816) gives horizontal width of screen -1

 319 = LCD
 719 = TV

How to tell if you are in PAL or NTSC mode

MLC_DPC_Y_MAX (0xc000 2818) gives the vertical height of the screen -1

 239 = LCD
 479 = NTSC
 575 = PAL

(These values are divided by 2 for me in tv-out mode. Mike)

Other information

  • Any program not altering default values will display okay,
  • Any program using GPH's SDL (or paeryn's HW-accelerated SDL <unashamed plug>) will have the scale registers set okay.
    • HW-accelerated SDL also allows creation of the screen in any resolution (upto 1024x768), (TV is 720x576 or 720x480), the scaler is set automagically to fill the screen.
Personal tools