int main() { int x; //u16 *framebuffer; framebuffer = (u16*) FRAMEBUFFER; gp_setCpuspeed(133); // 33 66 100 133 156 gp_initFramebuffer(framebuffer,16,85); for (x=0;x<320*240;x++) framebuffer[x]=0x0000; // Clear Screen /* Init Colormap */ init_colormap(); /* Init Scr */ scr1 = (unsigned char *) calloc ( W*(H+4) , 1 ); scr2 = (unsigned char *) calloc ( W*(H+4) , 1 ); while (1) { refresh (); conv (); } /* Free */ free (color); free (scr1); free (scr2); }
/* ######################## System functions ######################## */ void gp_Reset(void) { unsigned int i=0; gp_setCpuspeed(533); if( gp2x_sound_thread) { gp2x_sound_thread_exit=1; usleep(500); } MLCADDRESS0 = bkregs32[0]; MLCADDRESS1 = bkregs32[1]; MLCCONTROL0 = bkregs32[2]; MLCCONTROL1 = bkregs32[3]; MLCLEFTRIGHT0 = bkregs32[4]; MLCTOPBOTTOM0 = bkregs32[5]; MLCLEFTRIGHT1 = bkregs32[6]; MLCTOPBOTTOM1 = bkregs32[7]; MLCBGCOLOR = bkregs32[8]; MLCHSTRIDE0 = bkregs32[9]; MLCVSTRIDE0 = bkregs32[10]; MLCHSTRIDE1 = bkregs32[11]; MLCVSTRIDE1 = bkregs32[12]; DPCCTRL1 = bkregs32[13]; MLCSCREENSIZE = bkregs32[14]; lc_dirtylayer(0); lc_dirtylayer(1); lc_dirtymlc(); munmap((void *)memregs32, 0x20000); munmap(framebuffer_mmap[0], fb_size * BUFFERS); if (wiz_dev[0]) close(wiz_dev[0]); if (wiz_dev[1]) close(wiz_dev[1]); if (wiz_dev[2]) close(wiz_dev[2]); fcloseall(); chdir("/usr/gp2x"); execl("gp2xmenu",NULL); }
int main() { int i; Ball *ball; gp_setCpuspeed(133); gp_initFramebuffer(frameBuffer,16,80); for(i=0; i<BALLS; i++) { ball = &balls[i]; ball->x = (rand() % (320-64)); ball->y = (rand() % (240-64)); ball->dx = (rand() & 1)*2-1; /* -1 or 1 */ ball->dy = (rand() & 1)*2-1; } while(1) { gp_clearFramebuffer16(frameBuffer,0xFFFE); for(i=0; i<BALLS; i++) { ball = &balls[i]; ball->x += ball->dx; ball->y += ball->dy; if ( (ball->x < 0) || (ball->x > (320-64)) ) ball->dx = -ball->dx; if ( (ball->y < 0) || (ball->y > (240-64)) ) ball->dy = -ball->dy; gp_drawSpriteHTB((u16 *)spriteBall_bin,ball->x,ball->y,frameBuffer,0xFFFE,24); } gp_drawString(90,220,16,"Press A to reset",0x0000,frameBuffer); swapBuffers(); if ( gp_getButton()&BUTTON_A) gp_Reset(); } return 0; }
int main() { int refreshrate; framebuffer = (u16*) FRAMEBUFFER; gp_setCpuspeed(33); refreshrate = gp_initFramebuffer(framebuffer,16,80); gp_clearFramebuffer16(framebuffer,0xFFFF); gp_drawString(10,100,12,"Hello World!",0xf800,framebuffer); while (1) { if ( gp_getButton()&BUTTON_A) gp_Reset(); } }
int main() { double z; int x,y; double xmin=-2.5,xmax=2.0,ymin=-2.2,ymax=2.2; framebuffer = (u16*) FRAMEBUFFER; gp_setCpuspeed(133); gp_initFramebuffer(framebuffer,16,85); for (x=0;x<320*240;x++) framebuffer[x]=0xFFFF; // Clear Screen screen=framebuffer; //gp_SetCpuSpeed(156); mandelbrot(xmin,xmax,ymin,ymax,64); //gp_SetCpuSpeed(33); x=10;y=10; while (1) { short backup; backup = screen[x+240*y]; screen[x+240*y]=0xFFFF; for (z=0;z<5000;z++) z=z; screen[x+240*y]=backup; if ( gp_getButton()&BUTTON_RIGHT) y+=1; if ( gp_getButton()&BUTTON_LEFT ) y-=1; if ( gp_getButton()&BUTTON_UP ) x+=1; if ( gp_getButton()&BUTTON_DOWN ) x-=1; if (x>239) x=239; if (x<1) x=1; if (y>319) y=319; if (y<1) y=1; } while (1) { } }