int main(int argc, char * argv[]) { uint32_t generation = 0; init_gfx(); init_random(); run = true; init_world(); while(run) { SDL_Event sdl_ev; if (SDL_PollEvent(&sdl_ev) != 0) { if (sdl_ev.type == SDL_KEYDOWN) switch (sdl_ev.key.keysym.sym) { case SDLK_q: run = false; break; case SDLK_SPACE: pause = !pause; break; default: break; } } if (!pause) { draw(); SDL_Flip(surface); next_generation(); generation++; /* SDL_Delay(50); */ } } SDL_Quit(); return 0; }
int main(int argc, char** argv) { init_gfx(); init_2d(); // create world and set gravity world = dWorldCreate(); dWorldSetGravity(world, 0, -5, 0); // create a body for our ball dBodyID body = dBodyCreate(world); dBodySetPosition(body, 0, 0, 0); for (;;) { // infinite loop // get the position and move there in OpenGL const dReal* pos = dBodyGetPosition(body); glTranslatef(pos[0], pos[1], pos[2]); draw_circle(); // integrate all bodies dWorldQuickStep(world, 0.01); // redraw screen step(); } }
int init(void) { if (init_video() != 0) { fprintf(stderr, "Failed to initialize video\n"); return -1; } if (init_script() != 0) { fprintf(stderr, "Failed to initialize scripting engine\n"); return -1; } if (init_gfx() != 0) { fprintf(stderr, "Failed to initialize graphics\n"); return -1; } if (init_audio() != 0) { fprintf(stderr, "Failed to initialize audio\n"); return -1; } if (init_sdl() != 0) { fprintf(stderr, "Failed to initialize SDL\n"); return -1; } return 0; }
int main(int argc, char** argv) { init_gfx(); init_2d(); world = dWorldCreate(); dBodyID ball = dBodyCreate(world); dBodySetPosition(ball, 0, 0, 0); for (;;) { Uint8* chars = SDL_GetKeyState(NULL); if (chars[SDLK_LEFT]) { dBodyAddForce(ball, -force, 0, 0); } if (chars[SDLK_RIGHT]) { dBodyAddForce(ball, +force, 0, 0); } if (chars[SDLK_UP]) { dBodyAddForce(ball, 0, +force, 0); } if (chars[SDLK_DOWN]) { dBodyAddForce(ball, 0, -force, 0); } const dReal* pos = dBodyGetPosition(ball); glTranslatef(pos[0], pos[1], pos[2]); draw_circle(); dWorldQuickStep(world, 0.01); step(); } }
int main(int c, char **v) { init_gfx(&c, v); glutMainLoop(); return 0; }
int create_and_open_screen(int sizex, int sizey, int bpp, int mode) { static bool first = true; static bool dofree = false; #ifndef WIN32 set_sdl_env(); #endif if (dofree == true) { dofree = false; SDL_FreeSurface(gfx->buff); } if (first == true) { if (!(gfx = (t_gfx*)malloc(sizeof(*gfx)))) { printf("Out of memory.\n"); exit(42); } gfx->videoinfo = (SDL_VideoInfo *)SDL_GetVideoInfo(); first = false; } gfx->win = (t_display*)xmalloc(sizeof(*(gfx->win))); #ifdef GRAPHICS_DEBUG fprintf(fd_log, "Checking mode %dx%d@%dbpp.\n", sizex, sizey, bpp); #endif gfx->bpp = SDL_VideoModeOK(sizex, sizey, bpp, mode); if(!gfx->bpp) { #ifdef GRAPHICS_DEBUG fprintf(fd_log, "Mode not available, trying another..\n"); #endif gfx->bpp = SDL_VideoModeOK(sizex, sizey, bpp, SDL_ANYFORMAT); if (!gfx->bpp) return (-1); if (!(gfx->main = SDL_SetVideoMode(sizex, sizey, bpp, mode | SDL_GLSDL))) return (-1); } else if (!(gfx->main = SDL_SetVideoMode(sizex, sizey, bpp, mode | SDL_GLSDL))) return (-1); gfx->win->sdlMainScreen = gfx->main; gfx->win->text = NULL; SDL_WM_SetCaption("Freewar", "fw.ico"); gfx->buff = xSDL_DisplayFormatAlpha(gfx->main); init_gfx(); if (init_fonts()) return (-1); dofree = true; return (0); }
void init() { // HANDLE hCurrentProcess = GetCurrentProcess(); // SetPriorityClass(hCurrentProcess, REALTIME_PRIORITY_CLASS); if (SDL_Init(SDL_INIT_EVERYTHING) == -1) { trace("SDL initialization failed: %s.", SDL_GetError()); exit(1); } atexit(shutdown_app); srand((unsigned int)time(NULL)); // Graphics init init_gfx(X_AXIS, Y_AXIS); init_objects(); }
void init(marfbed_t * b) { init_random(); init_gfx(b); /* allocate marfs */ b->marf = malloc(MARF_MAX * sizeof(*b->marf)); if (!b->marf) { printf("ERROR: malloc(): %s\n", strerror(errno)); exit(1); } int i; for (i=0; i<MARF_MAX; i++) { b->marf[i].index = i; init_marf(&(b->marf[i])); //print_mac(&b->marf[i]); } }
int main(int argc, char** argv) { init_gfx(); init_2d(); world = dWorldCreate(); dBodyID ball = dBodyCreate(world); dBodySetPosition(ball, 0, 0, 0); for (;;) { Uint8* chars = SDL_GetKeyState(NULL); const dReal* pos = dBodyGetPosition(ball); const dReal* q = dBodyGetQuaternion(ball); double angle = get_q_angle(q); const dReal* axis = get_q_axis(q); if (chars[SDLK_LEFT]) { dBodyAddForceAtPos(ball, -force, 0, 0, pos[0], pos[1]+1, pos[2]); } if (chars[SDLK_RIGHT]) { dBodyAddForceAtPos(ball, force, 0, 0, pos[0], pos[1]+1, pos[2]); } if (chars[SDLK_UP]) { dBodyAddForce(ball, 0, +force, 0); } if (chars[SDLK_DOWN]) { dBodyAddForce(ball, 0, -force, 0); } glTranslatef(pos[0], pos[1], pos[2]); glRotatef(angle * 180 / M_PI, axis[0], axis[1], axis[2]); draw_circle(); dWorldQuickStep(world, 0.01); step(); } }
/* called function from outside */ enum plugin_status plugin_start(const void* parameter) { int i, rc; (void)parameter; #ifdef HAVE_LCD_COLOR rb->lcd_set_background(LCD_WHITE); rb->lcd_set_foreground(LCD_BLACK); #endif #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif rb->splash(HZ, "FlipIt!"); #ifdef HAVE_LCD_BITMAP /* print instructions */ rb->lcd_clear_display(); rb->lcd_setfont(FONT_SYSFIXED); #if CONFIG_KEYPAD == RECORDER_PAD rb->lcd_putsxy(2, 8, "[OFF] to stop"); rb->lcd_putsxy(2, 18, "[PLAY] toggle"); rb->lcd_putsxy(2, 28, "[F1] shuffle"); rb->lcd_putsxy(2, 38, "[F2] solution"); rb->lcd_putsxy(2, 48, "[F3] step by step"); #elif CONFIG_KEYPAD == ONDIO_PAD rb->lcd_putsxy(2, 8, "[OFF] to stop"); rb->lcd_putsxy(2, 18, "[MODE] toggle"); rb->lcd_putsxy(2, 28, "[M-LEFT] shuffle"); rb->lcd_putsxy(2, 38, "[M-UP] solution"); rb->lcd_putsxy(2, 48, "[M-RIGHT] step by step"); #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ (CONFIG_KEYPAD == IRIVER_H300_PAD) rb->lcd_putsxy(2, 8, "[STOP] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[MODE] shuffle"); rb->lcd_putsxy(2, 38, "[PLAY] solution"); rb->lcd_putsxy(2, 48, "[REC] step by step"); #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ (CONFIG_KEYPAD == IPOD_3G_PAD) || \ (CONFIG_KEYPAD == IPOD_1G2G_PAD) rb->lcd_putsxy(2, 8, "[S-MENU] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[S-LEFT] shuffle"); rb->lcd_putsxy(2, 38, "[S-PLAY] solution"); rb->lcd_putsxy(2, 48, "[S-RIGHT] step by step"); #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD rb->lcd_putsxy(2, 8, "[POWER] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[REC] shuffle"); rb->lcd_putsxy(2, 38, "[PLAY..] solution"); rb->lcd_putsxy(2, 48, "[PLAY] step by step"); #elif CONFIG_KEYPAD == GIGABEAT_PAD rb->lcd_putsxy(2, 8, "[POWER] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[MENU] shuffle"); rb->lcd_putsxy(2, 38, "[VOL+] solution"); rb->lcd_putsxy(2, 48, "[VOL-] step by step"); #elif CONFIG_KEYPAD == IRIVER_H10_PAD rb->lcd_putsxy(2, 8, "[POWER] to stop"); rb->lcd_putsxy(2, 18, "[REW] toggle"); rb->lcd_putsxy(2, 28, "[PL-LEFT] shuffle"); rb->lcd_putsxy(2, 38, "[PL-RIGHT] solution"); rb->lcd_putsxy(2, 48, "[PL-UP] step by step"); #elif CONFIG_KEYPAD == GIGABEAT_S_PAD rb->lcd_putsxy(2, 8, "[BACK] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[MENU] shuffle"); rb->lcd_putsxy(2, 38, "[VOL+] solution"); rb->lcd_putsxy(2, 48, "[VOL-] step by step"); #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ (CONFIG_KEYPAD == SANSA_C200_PAD) rb->lcd_putsxy(2, 8, "[POWER] to stop"); rb->lcd_putsxy(2, 18, "[SELECT] toggle"); rb->lcd_putsxy(2, 28, "[REC-LEFT] shuffle"); rb->lcd_putsxy(2, 38, "[REC-RIGHT] solution"); rb->lcd_putsxy(2, 48, "[REC-SEL] step by step"); #elif CONFIG_KEYPAD == IAUDIO_M3_PAD rb->lcd_putsxy(2, 8, "[REC] to stop"); rb->lcd_putsxy(2, 18, "[PLAY] toggle"); rb->lcd_putsxy(2, 28, "[MODE] shuffle"); rb->lcd_putsxy(2, 38, "[MENU..] solution"); rb->lcd_putsxy(2, 48, "[MENU] step by step"); #endif #ifdef HAVE_TOUCHSCREEN rb->lcd_putsxy(2, 8, "[BOTTOMLEFT] to stop"); rb->lcd_putsxy(2, 18, "[CENTRE] toggle"); rb->lcd_putsxy(2, 28, "[TOPRIGHT] shuffle"); rb->lcd_putsxy(2, 38, "[BOTTOMLEFT] solution"); rb->lcd_putsxy(2, 48, "[BOTTOMRIGHT] step by step"); #endif rb->lcd_update(); #else /* HAVE_LCD_CHARCELLS */ if (!init_gfx()) return PLUGIN_ERROR; #endif rb->button_get_w_tmo(HZ*3); rb->lcd_clear_display(); draw_info_panel(); for (i=0; i<20; i++) { spots[i]=1; draw_spot(i); } rb->lcd_update(); rb->sleep(HZ*3/2); rb->srand(*rb->current_tick); rc = flipit_loop(); #ifdef HAVE_LCD_CHARCELLS release_gfx(); #endif return rc; }
int main(int argc,char **argv) { INFO(char *dbg="Main(init): "); native_startup(argc, argv); /*** init modules ***/ INFO(printf("%sSharedMemory\n",dbg)); init_sharedmem(&dope); INFO(printf("%sTimer\n",dbg)); init_timer(&dope); INFO(printf("%sTick\n",dbg)); init_tick(&dope); INFO(printf("%sRelax\n",dbg)); init_relax(&dope); INFO(printf("%sKeymap\n",dbg)); init_keymap(&dope); INFO(printf("%sThread\n",dbg)); init_thread(&dope); INFO(printf("%sCache\n",dbg)); init_cache(&dope); INFO(printf("%sHashTable\n",dbg)); init_hashtable(&dope); INFO(printf("%sApplication Manager\n",dbg)); init_appman(&dope); INFO(printf("%sTokenizer\n",dbg)); init_tokenizer(&dope); INFO(printf("%sMessenger\n",dbg)); init_messenger(&dope); INFO(printf("%sScript\n",dbg)); init_script(&dope); INFO(printf("%sClipping\n",dbg)); init_clipping(&dope); INFO(printf("%sScreen Driver\n",dbg)); init_scrdrv(&dope); INFO(printf("%sInput\n",dbg)); init_input(&dope); INFO(printf("%sViewManager\n",dbg)); init_viewman(&dope); INFO(printf("%sConvertFNT\n",dbg)); init_conv_fnt(&dope); INFO(printf("%sFontManager\n",dbg)); init_fontman(&dope); INFO(printf("%sGfxScreen16\n",dbg)); init_gfxscr16(&dope); INFO(printf("%sGfxImage16\n",dbg)); init_gfximg16(&dope); INFO(printf("%sGfxImage32\n",dbg)); init_gfximg32(&dope); INFO(printf("%sGfxImageYUV420\n",dbg)); init_gfximgyuv420(&dope); INFO(printf("%sGfx\n",dbg)); init_gfx(&dope); INFO(printf("%sRedrawManager\n",dbg)); init_redraw(&dope); INFO(printf("%sUserState\n",dbg)); init_userstate(&dope); INFO(printf("%sWidgetManager\n",dbg)); init_widman(&dope); INFO(printf("%sScope\n",dbg)); init_scope(&dope); INFO(printf("%sButton\n",dbg)); init_button(&dope); INFO(printf("%sEntry\n",dbg)); init_entry(&dope); INFO(printf("%sVariable\n",dbg)); init_variable(&dope); INFO(printf("%sLabel\n",dbg)); init_label(&dope); INFO(printf("%sLoadDisplay\n",dbg)); init_loaddisplay(&dope); INFO(printf("%sBackground\n",dbg)); init_background(&dope); INFO(printf("%sScrollbar\n",dbg)); init_scrollbar(&dope); INFO(printf("%sScale\n",dbg)); init_scale(&dope); INFO(printf("%sFrame\n",dbg)); init_frame(&dope); INFO(printf("%sContainer\n",dbg)); init_container(&dope); INFO(printf("%sGrid\n",dbg)); init_grid(&dope); INFO(printf("%sWinLayout\n",dbg)); init_winlayout(&dope); INFO(printf("%sWindow\n",dbg)); init_window(&dope); INFO(printf("%sScreen\n",dbg)); init_screen(&dope); INFO(printf("%sScheduler\n",dbg)); if (config_don_scheduler) { // init_don_scheduler(&dope); printf("NOOOOOOOOOOOOOOOOOOO\n"); } else init_simple_scheduler(&dope); INFO(printf("%sVScreenServer\n",dbg)); init_vscr_server(&dope); INFO(printf("%sVScreen\n",dbg)); init_vscreen(&dope); INFO(printf("%sVTextScreen\n",dbg)); init_vtextscreen(&dope); INFO(printf("%sServer\n",dbg)); init_server(&dope); INFO(printf("%screate screen\n",dbg)); { static GFX_CONTAINER *scr_ds; gfx = pool_get("Gfx 1.0"); screen = pool_get("Screen 1.0"); userstate = pool_get("UserState 1.0"); scr_ds = gfx->alloc_scr("default"); curr_scr = screen->create(); curr_scr->scr->set_gfx(curr_scr, scr_ds); userstate->set_max_mx(gfx->get_width(scr_ds)); userstate->set_max_my(gfx->get_height(scr_ds)); } INFO(printf("%sstarting server\n",dbg)); if ((server = pool_get("Server 1.0"))) server->start(); INFO(printf("%sstarting scheduler\n",dbg)); if ((sched = pool_get("Scheduler 1.0"))) sched->process_mainloop(); return 0; }
int main() { long int delay; int brg; // Call the various initialization functions. init_osd(); setup_pll(); setup_io(); setup_int(); init_gfx(1); // Turn on doze, with a 1:1 ratio. CLKDIVbits.DOZEN = 0; CLKDIVbits.DOZE = 0b000; // Start in console mode. Print startup messages. con_init(); con_rolling = 0; con_puts("Super OSD v3.2-lite", 0); con_puts("dsPIC33F side", 0); con_puts("Copr. 2010 Tom O.", 0); ; con_puts("COMPILED FOR: ENGLISH", 0); con_puts("", 0); con_puts("Booting kernel [ OK ]", 0); con_puts("Verify 24F [ OK ]", 0); con_puts("Verify 33F [ OK ]", 0); con_puts("Switch to hi res [ OK ]", 0); init_gfx(0); if(mem_test_full()) { con_puts("VRAM test [ OK ]", 0); } else { con_puts("VRAM test [FAIL]", 0); con_puts("Check memory soon! ", 0); // Show warning for some time delay = 2000000; while(delay--); } // Clear graphics buffers of any memory test data remaining. init_gfx(0); con_puts("Init UART [ OK ]", 0); // BUG: occasionally resets processor on start up //interface_init_uart(); //brg = interface_set_baudrate(1843200); //sprintf(temp, "BRG=%d", brg); //con_puts(temp, 0); /* con_puts("PC detect... [FAIL]", 0); con_puts("GPS detect... [ OK ]", 0); con_puts("SPI initialized [ OK ]", 0); con_puts("Found flash mem [ OK ]", 0); con_puts(" Size: 2048 KB [ OK ]", 0); con_puts("USB not supported [SKIP]", 0); con_puts("Init GPS [ OK ]", 0); con_puts("Test I2C [ OK ]", 0); con_puts(" Xbee Adap. 2.0 [ OK ]", 0); con_puts(" LSM303 acc [ OK ]", 0); con_puts(" LSM303 mag [ OK ]", 0); con_puts(" ITG3200 gyro [FAIL]", 0); con_puts("Loading settings [ OK ]", 0); con_puts("Init splash [ OK ]", 0); */ // Demo HUD. //buffer_mode(0); con_puts("Launching hud_demo", 0); delayhowlong = 10000; hud_demo(); }
/* Intialize emulator with given ROM file, and * specify whether or not debug mode is active * (0 for OFF, any other value is on) * * returns 1 if successfully initialized, 0 * otherwise */ int init_emu(const char *file_path, int debugger, int dmg_mode, ClientOrServer cs) { uint8_t rom_header[0x50]; //Start logger set_log_level(LOG_INFO); log_message(LOG_INFO, "About to open file %s\n", file_path); FILE *file; if (!(file = PB_FOPEN(file_path,"rb"))) { log_message(LOG_ERROR, "Error opening file %s\n", file_path); return 0; } if ((PB_FSEEK(file, 0x100, SEEK_SET) != 0) || (PB_FREAD(rom_header, 1, sizeof(rom_header), file) != sizeof(rom_header))) { log_message(LOG_ERROR, "Error reading ROM header info\n"); fclose(file); return 0; }; PB_FCLOSE(file); log_message(LOG_INFO, "ROM Header loaded %s\n", file_path); if (!load_rom(file_path, rom_header, dmg_mode)) { log_message(LOG_ERROR, "failed to initialize GB memory\n"); return 0; } if (!init_gfx()) { log_message(LOG_ERROR, "Failed to initialize graphics\n"); return 0; } if (!setup_serial_io(cs, 5000)) { log_message(LOG_INFO, "No client or server created\n"); } init_joypad(); init_apu(); // Initialize sound reset_cpu(); if (debugger) { debug = 1; } cgb_features = is_colour_compatible() || is_colour_only(); //Log ROM info char name_buf[100]; int i; for(i = ROM_NAME_START; i <= ROM_NAME_END; i++) { name_buf[i - ROM_NAME_START] = get_mem(i); } name_buf[i - ROM_NAME_START] = '\0'; log_message(LOG_INFO,"Game Title: %s\n", name_buf); log_message(LOG_INFO,"Licensee: %s\n", get_licensee()); log_message(LOG_INFO,"Destination: %s\n", get_destination_code()); log_message(LOG_INFO,"ROM size: %dKB\n",get_rom_size()); log_message(LOG_INFO,"RAM save size: %dKB\n",get_ram_save_size()); const char *c_type = get_cartridge_type(); log_message(LOG_INFO,"Cartridge Type: %s\n",c_type != NULL ? c_type : "Unknown"); log_message(LOG_INFO, "Has Gameboy Color features: %s\n", is_colour_compatible() || is_colour_only() ? "Yes":"No"); log_message(LOG_INFO,"Gameboy Color Only Game:%s\n", is_colour_only() ? "Yes":"No"); log_message(LOG_INFO,"Super Gameboy Features:%s\n", has_sgb_features() ? "Yes":"No"); return 1; }