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); }
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) { } }
u32 Gdl_init(char* appTitle, u32 width, u32 height) // open you a framebuffer { #ifndef GP32 HEIGHT = height; WIDTH = width; #endif inikey(); #ifdef GP32 gp_enableCache(); screenRefreshRate = height; currentFrequency = width; gpSetCpuSpeed(currentFrequency); screenBuffer[0] = (clDeep*)FRAMEBUFFER1; screenBuffer[1] = (clDeep*)FRAMEBUFFER2; screenBufferEnd[0] = &( (screenBuffer[0])[(320*240)-1] ); screenBufferEnd[1] = &( (screenBuffer[1])[(320*240)-1] ); pixel = screenBuffer[nflip]; currentFps = gp_initFramebuffer(screenRefreshRate); gp_initRTC(); shell.set(-1,-1,24,14); shell.print("@0g@1d@0l @1i@0n@1i@0t @2ok\n"); //printlr("current fps : %i",currentFps); #endif #ifdef useSdl if(SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) { fprintf (stderr, "sdl init error (%s)\n",SDL_GetError()); return 0; } screen = SDL_SetVideoMode (WIDTH, HEIGHT, deepByte, SDL_SWSURFACE/*|SDL_NOFRAME*/ );// SDL_SWSURFACE)/; if(!screen) { fprintf (stderr, "error on set %ix%i.%i video mode (%s)\n", WIDTH,HEIGHT,deepByte,SDL_GetError()); return 0; } SDL_WM_SetCaption(appName,0); //SDL_ShowCursor(SDL_DISABLE); if(SDL_NumJoysticks() > 0) { joy = SDL_JoystickOpen(0); if(!joy) { fprintf (stderr, "sdl link to joystick error (%s)\n",SDL_GetError()); return 0; } } pixel = (clDeep*)(screen->pixels); SDL_UnlockSurface(screen); #endif #ifdef useRlyeh gp2x_init(1000, deepByte, 11025,16,1,60); pixel = gp2x_screen15; #endif #ifdef usePtc fwidth = WIDTH; fheight = HEIGHT; pixel = (clDeep*)malloc(WIDTH*HEIGHT*4); if(!ptc_open(appTitle,&fwidth,&fheight)) { showMsg("cannot render the backbuffer :|\n\nneed a minimum of :\n\t* 16b color deep\n\t* direct X 5 or more",appTitle); Gdl_exit(); } ptc_iniMsgCallBack(&Gdl_processMsg); #endif #ifndef GP32 #ifdef startAppWithFullPower Gdl_setAppPower(1); #else Gdl_setAppPower(0); #endif #endif //atexit (Gdl_exit); fullBlitLimit(); return 1; }
u32 gp_resetScreen(void) { return gp_initFramebuffer(screenRefreshRate); }