andrew_j_w
Still Fresh
- Joined
- Sep 18, 2005
- Messages
- 59
Hi all,
I've been banging my head against a break wall for the past day and I can't get the program below to work. It should just set the screen to white then quit. Problem is I see nothing when it run. The screen remains black.
If someone could point out where I've gone wrong that would be extremely appreciated.
Many thanks,
Andrew
I've been banging my head against a break wall for the past day and I can't get the program below to work. It should just set the screen to white then quit. Problem is I see nothing when it run. The screen remains black.
If someone could point out where I've gone wrong that would be extremely appreciated.
Code:
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/time.h>
unsigned short* GP2x_registers;
unsigned long GP2x_screen_addr;
void* GP2x_screen;
int main(int argc, char* argv[]) {
struct fb_fix_screeninfo fixed_info;
int fd_memory = open("/dev/mem", O_RDWR);
int fd_fb0 = open("/dev/fb0", O_RDWR);
GP2x_registers = (unsigned short*)mmap(0, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd_memory, 0xc0000000);
GP2x_screen = (unsigned short*)mmap(0, 320*240*2, PROT_WRITE, MAP_SHARED, fd_fb0, 0);
GP2x_registers[0x290C>>1]= (unsigned short)0x04ab; /* set RGB bpp (8,15/16); enable RGB window 1 */
GP2x_registers[0x28DA>>1]= (unsigned short)0x0280; /* hex(640) */
/* Get the memory locations of the framebuffers. */
ioctl(fd_fb0, FBIOGET_FSCREENINFO, &fixed_info);
GP2x_screen_addr = fixed_info.smem_start;
memset(GP2x_screen, 255, 320*240*2);
GP2x_registers[(0x290E)>>1] = GP2x_registers[(0x2912)>>1] = (unsigned short)(GP2x_screen_addr & 0xFFFF);
GP2x_registers[(0x2910)>>1] = GP2x_registers[(0x2914)>>1] = (unsigned short)(GP2x_screen_addr >> 16);
}
Many thanks,
Andrew