#include #include #include #include #include #include #include #include #include "hardware.h" #include "moon-zipit.h" volatile unsigned int* pallsw = (unsigned int*)(CLPS7111_VIRT_BASE+PALLSW); volatile unsigned int* palmsw = (unsigned int*)(CLPS7111_VIRT_BASE+PALMSW); int main(int argc, char*argv[]) { int fbfd = 0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; long int screensize = 0; char *fbp = 0; int x = 0, y = 0; //long int location = 0; unsigned int pl,pm; unsigned char buf[320]; // save pallette pl = *pallsw; pm = *palmsw; /* Open the file for reading and writing */ fbfd = open("/dev/fb0", O_RDWR); if (!fbfd) { fprintf(stderr,"fbtest: cannot open framebuffer device\n"); exit(1); } /* Get fixed screen information */ if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { fprintf(stderr,"fbtest: reading fixed information\n"); exit(2); } /* Get variable screen information */ if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { fprintf(stderr,"fbtest: reading variable information\n"); exit(3); } /* Figure out the size of the screen in bytes */ screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; /* Map the device to memory */ fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if ((int)fbp == -1) { fprintf(stderr,"fbtest: failed to map framebuffer device to memory\n"); exit(4); } // set pallette //*pallsw = 0x76543210; //*palmsw = 0xfedcba98; *pallsw = 0x89abcdef; *palmsw = 0x01234567; // read and draw image const char* data = header_data; for (y=0; y<240; ++y) { for (x=0; x<160; ++x) { fbp[y*160+x] = (data[1]<<4) + data[0]; data += 2; } } // read a key fgets(buf,16,stdin); /* restore pallette and clear screen */ *pallsw = pl; *palmsw = pm; memset(fbp,0,screensize); munmap(fbp, screensize); close(fbfd); return 0; }