Programming Tv Out


parisgraphics

Still Fresh
Joined
Dec 26, 2006
Messages
6
Website
www.parisgraphics.com
Hi All,

I just received a gp2x for x-mas and love it.
I have some programming experience but am new to the specifics of this hardware.
I want to write programs that can use the TV out - what do I need to know?
Or is this something that can be done with some kind of utility to any program, e.g. something written in Python/Pygame?

Thanks,
paris
 
Anything using SDL will automagically work with TV-Out... *Bonus Pretzel* but if you want to be hitting the hardware directly I'd say start hacking about and stuff, maybe ask rlyeh or some of the other code guru's around here what they've been able to find out.
 
I've always wanted to make something that makes use of the capabilities of the tv out, but I'm too lazy. Good luck to you.
 
If you're using SDL the only thing you have to be careful of is the screen size. On the gp2x, the screen res is 320x240, and on TV PAL is 720x288 and NTSC is 720x240. If you just use 320x240 all the time, SDL will scale it slightly on the TV so it will look a bit messy, so you'll have to either adjust your screen to 360x288 (or 360x240) or just use a temp 320x240 surface and always blit that to the centre of whatever you set the main surface to be (so you get slight black borders but no nasty scaling).
 
somewhat related... is there a way to check if the tv out is enabled from a program? Would be useful for having it autoswitch to the other resolution, if tv out is selected.
 
You can check the width and height of the actual screen (and from that decide if TV is enabled or not) by reading a couple of the registers. Found this code sitting around in one of my old files - the defines came from mmsp2_regs.h which is in Paeryn's SDL.
Code:
int memory_fd;
unsigned short volatile *io;
memory_fd = open("/dev/mem", O_RDWR, 0);
io=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE,MAP_SHARED, memory_fd, 0xc0000000);

#define DPC_X_MAX		(0x2816>>1)
#define DPC_Y_MAX		(0x2818>>1)
int phys_width,phys_height;
phys_width = io[DPC_X_MAX] + 1;
phys_height = io[DPC_Y_MAX] + 1;
 
Back
Top