void swapBuffers() { if (frameBuffer == (u16*)FRAMEBUFFER1) { gp_setFramebuffer((u16 *)FRAMEBUFFER1,1); frameBuffer = (u16 *)FRAMEBUFFER2; } else { gp_setFramebuffer((u16 *)FRAMEBUFFER2,1); frameBuffer = (u16 *)FRAMEBUFFER1; } }
bool8_32 S9xDeinitUpdate (int Width, int Height, bool8_32) { #if defined (__WIZ__) if ( snesMenuOptions.renderMode == RENDER_MODE_SCALED) #else if ( snesMenuOptions.renderMode == RENDER_MODE_SCALED && oldHeight!=Height) #endif { gp_video_RGB_setscaling(256,Height); oldHeight=Height; } #if defined (__WIZ__) else if ( snesMenuOptions.renderMode == RENDER_MODE_HORIZONTAL_SCALED) { gp_video_RGB_setHZscaling(256,Height); oldHeight=Height; } #endif if (snesMenuOptions.showFps) { unsigned int *pix; pix=(unsigned int*)framebuffer16[currFB]; for(int i=8;i;i--) { *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; pix+=128; } gp_drawString(0,0,strlen(fps_display),fps_display,0xFFFF,(unsigned char*)framebuffer16[currFB]); } // TODO clear Z buffer if not in fastsprite mode gp_setFramebuffer(currFB,0); }
void gp_initGraphics(unsigned short bpp, int flip, int applyMmuHack) { int x = 0; unsigned int key = 0; unsigned int offset = 0; char buf[256]; struct fb_fix_screeninfo info; int fb_fd; int f; gp_setClipping(0, 0, 319, 239); #ifdef DEBUG printf("Entering gp_initGraphics....\r\n"); #endif /* First check that frame buffer memory has not already been setup */ if (!InitFramebuffer) { #ifdef DEBUG sprintf(buf, "Initing buffer\r\n"); printf(buf); #endif wiz_dev[0] = open("/dev/mem", O_RDWR); if(wiz_dev[0] < 0) { printf("Could not open /dev/mem\n"); return; } #ifdef DEBUG sprintf(buf, "Devices opened\r\n"); printf(buf); sprintf(buf, "/dev/mem: %x \r\n", wiz_dev[0]); printf(buf); #endif memregs32 = (volatile unsigned int *)mmap(0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, wiz_dev[0], 0xC0000000); if(memregs32 == (volatile unsigned int *)0xFFFFFFFF) { printf("Could not mmap hardware registers\n"); return; } memregs16 = (volatile unsigned short *)memregs32; memregs8 = (volatile unsigned char *)memregs32; /* backup old register values to restore upon exit */ bkregs32[0] = MLCADDRESS0; bkregs32[1] = MLCADDRESS1; bkregs32[2] = MLCCONTROL0; bkregs32[3] = MLCCONTROL1; bkregs32[4] = MLCLEFTRIGHT0; bkregs32[5] = MLCTOPBOTTOM0; bkregs32[6] = MLCLEFTRIGHT1; bkregs32[7] = MLCTOPBOTTOM1; bkregs32[8] = MLCBGCOLOR; bkregs32[9] = MLCHSTRIDE0; bkregs32[10] = MLCVSTRIDE0; bkregs32[11] = MLCHSTRIDE1; bkregs32[12] = MLCVSTRIDE1; bkregs32[13] = DPCCTRL1; bkregs32[14] = MLCSCREENSIZE; bkregs32[15] = PLLSETREG0; // Get frame buffer address, do not hardcode them, for tv-out compatibility fb_fd = open("/dev/fb0", O_RDWR); if ((!fb_fd) || (ioctl(fb_fd, FBIOGET_FSCREENINFO, &info) < 0)) return; wiz_physvram[0] = info.smem_start; framebuffer_mmap[0] = (void *)mmap(0, fb_size * BUFFERS, PROT_READ|PROT_WRITE, MAP_SHARED, wiz_dev[0], wiz_physvram[0]); for (f = 1; f < BUFFERS; f++) { framebuffer_mmap[f] = framebuffer_mmap[f-1] + (fb_size / sizeof(unsigned short)); wiz_physvram[f] = wiz_physvram[f-1] + fb_size; } close(fb_fd); if (applyMmuHack) { warm_init(); warm_change_cb_upper(WCB_C_BIT|WCB_B_BIT, 1); } // Init and clear the frame buffers for (f = 0; f < BUFFERS; f++) { memset(framebuffer_mmap[f], 0, fb_size); framebuffer16[f] = framebuffer_mmap[f]; } /* Not working well with TV-Out // offset externally visible buffers by 8 // this allows DrMD to not worry about clipping framebuffer16[0]=framebuffer_mmap[0]+8; framebuffer16[1]=framebuffer_mmap[1]+8; framebuffer16[2]=framebuffer_mmap[2]+8; framebuffer16[3]=framebuffer_mmap[3]+8; //ofset physical buffer as well wiz_physvram[0]+=16; wiz_physvram[1]+=16; wiz_physvram[2]+=16; wiz_physvram[3]+=16; */ InitFramebuffer=1; } // Set graphics mode lc_screensize(320, 240); lc_setbgcol(0x000000); /* set default background colour */ lc_layerpos(0, 0, 0, 319, 239); /* set default layer positions */ lc_layerpos(1, 0, 0, 319, 239); lc_setlayer(0, 0, 0, 0, 0, RGB565); /* set default layer settings */ lc_setlayer(1, 1, 0, 0, 0, RGB565); gp_setFramebuffer(flip,1); usleep(100000); pollux_set(memregs16, "lcd_timings=397,1,37,277,341,0,17,337;dpc_clkdiv0=9"); pollux_set(memregs16, "ram_timings=2,9,4,1,1,1,1"); #ifdef DEBUG printf("Leaving gp_initGraphics....\r\n"); #endif }
void gp_initGraphics(unsigned short bpp, int flip, int applyMmuHack) { int x = 0; unsigned int key = 0; unsigned int offset = 0; char buf[256]; #ifdef DEBUG printf("Entering gp_initGraphics....\r\n"); #endif /* First check that frame buffer memory has not already been setup */ if (!InitFramebuffer) { #ifdef DEBUG sprintf(buf, "Initing buffer\r\n"); printf(buf); #endif wiz_dev[0] = open("/dev/mem", O_RDWR); if(wiz_dev[0] < 0) { printf("Could not open /dev/mem\n"); return; } #ifdef DEBUG sprintf(buf, "Devices opened\r\n"); printf(buf); sprintf(buf, "/dev/mem: %x \r\n", wiz_dev[0]); printf(buf); #endif memregs32 = (volatile unsigned int *)mmap(0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, wiz_dev[0], 0xC0000000); if(memregs32 == (volatile unsigned int *)0xFFFFFFFF) { printf("Could not mmap hardware registers\n"); return; } memregs16 = (volatile unsigned short *)memregs32; memregs8 = (volatile unsigned char *)memregs32; /* backup old register values to restore upon exit */ bkregs32[0] = MLCADDRESS0; bkregs32[1] = MLCADDRESS1; bkregs32[2] = MLCCONTROL0; bkregs32[3] = MLCCONTROL1; bkregs32[4] = MLCLEFTRIGHT0; bkregs32[5] = MLCTOPBOTTOM0; bkregs32[6] = MLCLEFTRIGHT1; bkregs32[7] = MLCTOPBOTTOM1; bkregs32[8] = MLCBGCOLOR; bkregs32[9] = MLCHSTRIDE0; bkregs32[10] = MLCVSTRIDE0; bkregs32[11] = MLCHSTRIDE1; bkregs32[12] = MLCVSTRIDE1; bkregs32[13] = DPCCTRL1; bkregs32[14] = MLCSCREENSIZE; bkregs32[15] = PLLSETREG0; if (!framebuffer_mmap[0]) framebuffer_mmap[0]=(void *)mmap(0, fb_size, PROT_READ|PROT_WRITE, MAP_SHARED, wiz_dev[0], (wiz_physvram[0]=0x04000000-(0x26000*4) )); if (!framebuffer_mmap[1]) framebuffer_mmap[1]=(void *)mmap(0, fb_size, PROT_READ|PROT_WRITE, MAP_SHARED, wiz_dev[0], (wiz_physvram[1]=0x04000000-(0x26000*3) )); if (!framebuffer_mmap[2]) framebuffer_mmap[2]=(void *)mmap(0, fb_size, PROT_READ|PROT_WRITE, MAP_SHARED, wiz_dev[0], (wiz_physvram[2]=0x04000000-(0x26000*2) )); if (!framebuffer_mmap[3]) framebuffer_mmap[3]=(void *)mmap(0, fb_size, PROT_READ|PROT_WRITE, MAP_SHARED, wiz_dev[0], (wiz_physvram[3]=0x04000000-(0x26000*1) )); if (applyMmuHack) { warm_init(); warm_change_cb_upper(WCB_C_BIT|WCB_B_BIT, 1); } // Clear the frame buffers memset(framebuffer_mmap[0],0,fb_size); memset(framebuffer_mmap[1],0,fb_size); memset(framebuffer_mmap[2],0,fb_size); memset(framebuffer_mmap[3],0,fb_size); // offset externally visible buffers by 8 // this allows DrMD to not worry about clipping framebuffer16[0]=framebuffer_mmap[0]+8; framebuffer16[1]=framebuffer_mmap[1]+8; framebuffer16[2]=framebuffer_mmap[2]+8; framebuffer16[3]=framebuffer_mmap[3]+8; //ofset physical buffer as well wiz_physvram[0]+=16; wiz_physvram[1]+=16; wiz_physvram[2]+=16; wiz_physvram[3]+=16; InitFramebuffer=1; //gp2x_memregs[0x0F16>>1] = 0x830a; //usleep(1000000); //gp2x_memregs[0x0F58>>1] = 0x100c; //usleep(1000000); } // Set graphics mode lc_screensize(320, 240); lc_setbgcol(0x000000); /* set default background colour */ lc_layerpos(0, 0, 0, 319, 239); /* set default layer positions */ lc_layerpos(1, 0, 0, 319, 239); lc_setlayer(0, 0, 0, 0, 0, RGB565); /* set default layer settings */ lc_setlayer(1, 1, 0, 0, 0, RGB565); gp_setFramebuffer(flip,1); usleep(100000); pollux_set(memregs16, "lcd_timings=397,1,37,277,341,0,17,337;dpc_clkdiv0=9"); pollux_set(memregs16, "ram_timings=2,9,4,1,1,1,1"); #ifdef DEBUG printf("Leaving gp_initGraphics....\r\n"); #endif }
void gp_initGraphics(unsigned short bpp, int flip, int applyMmuHack) { int x = 0; unsigned int key = 0; unsigned int offset = 0; char buf[256]; int i = 0; int fd = -1; #ifdef DEBUG printf("Entering gp_initGraphics....\r\n"); #endif /* First check that frame buffer memory has not already been setup */ if (!InitFramebuffer) { #ifdef DEBUG sprintf(buf, "Initing buffer\r\n"); printf(buf); #endif fb_dev = open("/dev/fb1", O_RDWR); if(fb_dev < 0) { printf("Could not open frame buffer device\n"); return; } #ifdef DEBUG sprintf(buf, "Devices opened\r\n"); printf(buf); sprintf(buf, "/dev/fb1: %x \r\n", fb_dev); printf(buf); #endif // Get fixed screen information if (ioctl(fb_dev, FBIOGET_FSCREENINFO, &finfo)) { printf("Error reading fixed information.\n"); return; } // Get variable screen information if (ioctl(fb_dev, FBIOGET_VSCREENINFO, &vinfo)) { printf("Error reading variable information.\n"); return; } // Figure out the size of one buffer in bytes fb_size = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; #ifdef DEBUG sprintf(buf, "FB: %dx%d @ %dbpp = %d bytes (%d for 4 screens)\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel, fb_size, fb_size*4); printf(buf); #endif if (!framebuffer_mmap) framebuffer_mmap = mmap(0, fb_size*4, PROT_READ|PROT_WRITE, MAP_SHARED, fb_dev, 0 ); // Clear the frame buffers memset(framebuffer_mmap,0,fb_size); framebuffer16[0]=(unsigned short*)(framebuffer_mmap); framebuffer16[1]=(unsigned short*)(framebuffer_mmap + (fb_size) ); framebuffer16[2]=(unsigned short*)(framebuffer_mmap + (fb_size*2) ); framebuffer16[3]=(unsigned short*)(framebuffer_mmap + (fb_size*3) ); #ifdef DEBUG { int i = 0; for( i = 0 ; i < 4 ; i++ ) { sprintf(buf, "FB%d @ 0x%x ", i, (void*)framebuffer16[i] ); printf(buf); sprintf(buf, "yoffset = %d\n", vinfo.yres * i ); printf(buf); } } #endif InitFramebuffer=1; } gp_setFramebuffer(flip,1); // Open devices to capture keyboard events if( key_devs == 0 ) { for( i = 0; 1 ; i++ ) { sprintf( buf, "/dev/input/event%i", i ); fd = open( buf, O_RDONLY|O_NONBLOCK ); if( fd < 0 ) { // No more devices break; } ioctl( fd, EVIOCGNAME(sizeof(buf)), buf ); if( strcmp( buf, "keypad" ) == 0 || strcmp( buf, "gpio-keys" ) == 0 ) { #ifdef DEBUG printf("Key device: /dev/input/event%i\n", i); #endif key_dev[key_devs++] = fd; } else { #ifdef DEBUG printf("Skipping: /dev/input/event%i (%s)\n", i, buf); #endif close( fd ); } } } #ifdef DEBUG printf("Leaving gp_initGraphics....\r\n"); #endif }
bool8_32 S9xDeinitUpdate (int Width, int Height, bool8_32) { #if defined (__WIZ__) if ( snesMenuOptions.renderMode == RENDER_MODE_SCALED) #else if ( snesMenuOptions.renderMode == RENDER_MODE_SCALED && oldHeight!=Height) #endif { gp_video_RGB_setscaling(256,Height); oldHeight=Height; } #if defined (__WIZ__) else if ( snesMenuOptions.renderMode == RENDER_MODE_HORIZONTAL_SCALED) { gp_video_RGB_setHZscaling(256,Height); oldHeight=Height; } #endif if ((CPU.SRAMModified) && (snesMenuOptions.autoSram == 2)) Draw16x16Image(framebuffer16[currFB], 320-16, 240-16, disk_img); if (snesMenuOptions.showFps) { unsigned int *pix; pix=(unsigned int*)framebuffer16[currFB]; for(int i=8;i;i--) { *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; *pix++ = 0x0; pix+=128; } gp_setClipping(0, 0, 319, 239); gp_drawString(0,0,strlen(fps_display),fps_display,0xFFFF,(unsigned char*)framebuffer16[currFB]); } gp_setFramebuffer(currFB,0); }