int main() { mainInit(); console_clrscr(); printf( "Welcome to the beginning...\n\n" "A graphical interface coming\nsomewhere down the line.\n"); struct controller_data_s c; while(1) { if (get_controller_data(&c, 0)) { if(c.a) printf("A\n"); if(c.b) printf("B\n"); if(c.x) printf("X\n"); if(c.y) printf("Y\n"); if(c.logo) printf("Logo/Guide\n"); if(c.lb) printf("Left Bumper\n"); if(c.rb) printf("Right Bumper\n"); if(c.up) printf("Up\n"); if(c.down) printf("Down\n"); if(c.left) printf("Left\n"); if(c.right) printf("Right\n"); if(c.lt) printf("Left Tigger\n"); if(c.rt) printf("Right Trigger\n"); if(c.start) printf("Start\n"); if(c.back) printf("Back/Select\n"); if(c.s1_x) printf("Stick 1 X: %d\n",c.s1_x); } usb_do_poll(); } return 0; }
int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(windowWidth,windowHeight); glutInitWindowPosition(windowXPos,windowYPos); /** Store main window id so that glui can send it redisplay events */ mainWindowId = glutCreateWindow("TF"); glutDisplayFunc(mainRender); glutReshapeFunc(onWindowReshape); /** Register keyboard events handlers */ glutKeyboardFunc(onKeyDown); glutKeyboardUpFunc(onKeyUp); mainInit(); glutMainLoop(); return 0; }
void main() { static TICK t = 0; CAN_MESSAGE outCm; // Inits mainInit(); #ifdef USE_CAN canInit(); #endif tickInit(); // Read ID and NID if exist. if (EERead(NODE_ID_EE)==NODE_HAS_ID) { MY_ID=(((WORD)EERead(NODE_ID_EE + 1))<<8)+EERead(NODE_ID_EE + 2); MY_NID=EERead(NODE_ID_EE + 3); } // Send user program startup heatbeat outCm.funct = FUNCT_BOOTLOADER; outCm.funcc = FUNCC_BOOT_HEARTBEAT; outCm.nid = MY_NID; outCm.sid = MY_ID; outCm.data_length = 1; outCm.data[BOOT_DATA_HEARTBEAT_INDEX] = HEARTBEAT_USER_STARTUP; while(!canSendMessage(outCm,PRIO_HIGH)); while(1) { static TICK t = 0; static TICK heartbeat = 0; if ((tickGet()-heartbeat)>TICK_SECOND*5) { // Send alive heartbeat outCm.funct = FUNCT_BOOTLOADER; outCm.funcc = FUNCC_BOOT_HEARTBEAT; outCm.nid = MY_NID; outCm.sid = MY_ID; outCm.data_length = 1; outCm.data[BOOT_DATA_HEARTBEAT_INDEX] = HEARTBEAT_ALIVE; while(!canSendMessage(outCm,PRIO_HIGH)); heartbeat = tickGet(); } if ((tickGet()-t)>TICK_SECOND) { LED0_IO=~LED0_IO; t = tickGet(); } } }
int main(){ mainInit(); usb_init(); fatInitDefault (); usb_do_poll(); debug("This will be logged to USB."); printf("This will be output to the console and UART."); }
int main(int argc, char *argv[]) { std::cout << "W - andar para frente" << std::endl; std::cout << "S - andar para tras" << std::endl; std::cout << "A - girar para a esquerda" << std::endl; std::cout << "D - girar para a esquerda" << std::endl; std::cout << "F - empurrar inimigo" << std::endl; std::cout << "V - trocar a câmera" << std::endl; std::cout << "SPACE - criar rachadura" << std::endl; std::cout << std::endl << std::endl; glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(windowWidth, windowHeight); glutInitWindowPosition(windowXPos, windowYPos); // Main Window mainWindowId = glutCreateWindow(GAME_NAME); glutDisplayFunc(mainRender); glutReshapeFunc(onWindowReshape); glutKeyboardFunc(onKeyDown); glutKeyboardUpFunc(onKeyUp); mainInit(); // Initial Screen /*initialScreenId = glutCreateSubWindow(mainWindowId, 0, 0, windowWidth, windowHeight); glutDisplayFunc(showInitialScreen); glutReshapeFunc(onWindowReshape); glutKeyboardFunc(onKeyDown); glutKeyboardUpFunc(onKeyUp); screenInit();*/ // Mini Map miniMapId = glutCreateSubWindow(mainWindowId, 0, 0,(windowWidth/3) - 40, (windowHeight/3) - 40); glutDisplayFunc(miniMapRender); glutReshapeFunc(onWindowReshape); mainInit(); PlaySound("Sounds\\56_Rocket_Tower_Takeover.wav", NULL, SND_ASYNC|SND_FILENAME|SND_LOOP|SND_NOSTOP ); glutMainLoop(); return 0; }
int main() { mainInit(); if (buttonIsPressed()) controllerCalibrate(); ledOn(); s_started = 1; while(1) { mainBluetooth(); mainSensors(); } return 0; }
int main(){ printf("Xenos/console init!"); mainInit(); uint8_t msg[16]; while(1) { memset(msg, 0, 16); msg[0] = 0x16; xenon_smc_send_message(msg); f_xenon_smc_receive_response(msg); } return 0; }
int main(void) { mainInit(); printf("test"); int i = 0; uint8_t first; uint8_t second; while(1) { first = 0; second = 0; first = (uint8_t)USART_Receive(); if(first != 0xff && first != 0xaa && first != 0x00) continue; second = (uint8_t)USART_Receive(); if(first == 0xff) SERVO_set(second << 2); if(first == 0xaa) MOTOR_setRef(second); if(first == 0x00 && second == 0x00) SOLENOID_fire(); } }
void PreMain() { systemDatInit(); systemInit(); testabilityDatInit(); stdlibparseutilsDatInit(); stdlibstrutilsDatInit(); stdlibtimesDatInit(); stdlibposixDatInit(); stdlibosDatInit(); listsDatInit(); stdlibhashesDatInit(); stdlibstrtabsDatInit(); stdlibstreamsDatInit(); stdlibosprocDatInit(); stdlibmathDatInit(); stdlibsetsDatInit(); optionsDatInit(); stdlibtablesDatInit(); platformDatInit(); crcDatInit(); ropesDatInit(); stdlibunsignedDatInit(); stdlibsocketsDatInit(); msgsDatInit(); nversionDatInit(); identsDatInit(); condsymsDatInit(); extccompDatInit(); wordrecgDatInit(); babelcmdDatInit(); commandsDatInit(); llstreamDatInit(); nimlexbaseDatInit(); lexerDatInit(); nimconfDatInit(); stdlibintsetsDatInit(); idgenDatInit(); astDatInit(); rodutilsDatInit(); astalgoDatInit(); parserDatInit(); pbracesDatInit(); rendererDatInit(); filtersDatInit(); filter_tmplDatInit(); syntaxesDatInit(); treesDatInit(); typesDatInit(); stdlibmemfilesDatInit(); rodreadDatInit(); magicsysDatInit(); bitsetsDatInit(); nimsetsDatInit(); passesDatInit(); treetabDatInit(); vmdefDatInit(); semdataDatInit(); lookupsDatInit(); importerDatInit(); rodwriteDatInit(); saturateDatInit(); semfoldDatInit(); procfindDatInit(); pragmasDatInit(); semtypinstDatInit(); parampatternsDatInit(); stdliblexbaseDatInit(); stdlibunicodeDatInit(); stdlibjsonDatInit(); docutilsrstastDatInit(); docutilsrstDatInit(); docutilshighliteDatInit(); docutilsrstgenDatInit(); guardsDatInit(); sempass2DatInit(); stdlibmacrosDatInit(); stdlibxmltreeDatInit(); stdlibcookiesDatInit(); stdlibcgiDatInit(); typesrendererDatInit(); docgenDatInit(); stdlibalgorithmDatInit(); stdlibsequtilsDatInit(); prettyDatInit(); sigmatchDatInit(); cgmethDatInit(); loweringsDatInit(); lambdaliftingDatInit(); transfDatInit(); vmgenDatInit(); vmdepsDatInit(); evaltemplDatInit(); vmDatInit(); aliasesDatInit(); patternsDatInit(); semmacrosanityDatInit(); semDatInit(); ccgutilsDatInit(); cgendataDatInit(); ccgmergeDatInit(); cgenDatInit(); jsgenDatInit(); passauxDatInit(); dependsDatInit(); docgen2DatInit(); stdlibparseoptDatInit(); serviceDatInit(); modulesDatInit(); mainDatInit(); nimrodDatInit(); initStackBottom(); testabilityInit(); stdlibparseutilsInit(); stdlibstrutilsInit(); stdlibtimesInit(); stdlibposixInit(); stdlibosInit(); listsInit(); stdlibhashesInit(); stdlibstrtabsInit(); stdlibstreamsInit(); stdlibosprocInit(); stdlibmathInit(); stdlibsetsInit(); optionsInit(); stdlibtablesInit(); platformInit(); crcInit(); ropesInit(); stdlibunsignedInit(); stdlibsocketsInit(); msgsInit(); nversionInit(); identsInit(); condsymsInit(); extccompInit(); wordrecgInit(); babelcmdInit(); commandsInit(); llstreamInit(); nimlexbaseInit(); lexerInit(); nimconfInit(); stdlibintsetsInit(); idgenInit(); astInit(); rodutilsInit(); astalgoInit(); parserInit(); pbracesInit(); rendererInit(); filtersInit(); filter_tmplInit(); syntaxesInit(); treesInit(); typesInit(); stdlibmemfilesInit(); rodreadInit(); magicsysInit(); bitsetsInit(); nimsetsInit(); passesInit(); treetabInit(); vmdefInit(); semdataInit(); lookupsInit(); importerInit(); rodwriteInit(); saturateInit(); semfoldInit(); procfindInit(); pragmasInit(); semtypinstInit(); parampatternsInit(); stdliblexbaseInit(); stdlibunicodeInit(); stdlibjsonInit(); docutilsrstastInit(); docutilsrstInit(); docutilshighliteInit(); docutilsrstgenInit(); guardsInit(); sempass2Init(); stdlibmacrosInit(); stdlibxmltreeInit(); stdlibcookiesInit(); stdlibcgiInit(); typesrendererInit(); docgenInit(); stdlibalgorithmInit(); stdlibsequtilsInit(); prettyInit(); sigmatchInit(); cgmethInit(); loweringsInit(); lambdaliftingInit(); transfInit(); vmgenInit(); vmdepsInit(); evaltemplInit(); vmInit(); aliasesInit(); patternsInit(); semmacrosanityInit(); semInit(); ccgutilsInit(); cgendataInit(); ccgmergeInit(); cgenInit(); jsgenInit(); passauxInit(); dependsInit(); docgen2Init(); stdlibparseoptInit(); serviceInit(); modulesInit(); mainInit(); }
N_CDECL(void, NimMain)(void) { nim__datInit(); systemInit(); parseutilsInit(); strutilsInit(); timesInit(); posixInit(); osInit(); listsInit(); nhashesInit(); nstrtabsInit(); optionsInit(); msgsInit(); nversionInit(); crcInit(); platformInit(); ropesInit(); identsInit(); astInit(); rodutilsInit(); astalgoInit(); condsymsInit(); hashesInit(); strtabsInit(); streamsInit(); osprocInit(); extccompInit(); wordrecgInit(); commandsInit(); llstreamInit(); lexbaseInit(); scannerInit(); nimconfInit(); pnimsynInit(); pbracesInit(); rnimsynInit(); filtersInit(); ptmplsynInit(); syntaxesInit(); rodreadInit(); treesInit(); typesInit(); mathInit(); magicsysInit(); bitsetsInit(); nimsetsInit(); passesInit(); treetabInit(); semdataInit(); lookupsInit(); importerInit(); rodwriteInit(); semfoldInit(); evalsInit(); procfindInit(); pragmasInit(); suggestInit(); semInit(); rstInit(); highliteInit(); docgenInit(); ccgutilsInit(); cgmethInit(); cgenInit(); ecmasgenInit(); interactInit(); passauxInit(); dependsInit(); transfInit(); mainInit(); parseoptInit(); nimrodInit(); }
int main(int argc, char **argv) { mainInit(argc,argv); return 0; }
/**Function******************************************************************** Synopsis [Main program for ntr.] Description [Main program for ntr. Performs initialization. Reads command line options and network(s). Builds BDDs with reordering, and optionally does reachability analysis. Prints stats.] SideEffects [None] SeeAlso [] ******************************************************************************/ int main( int argc, char ** argv) { NtrOptions *option; /* options */ FILE *fp1; /* first network file pointer */ BnetNetwork *net1 = NULL; /* first network */ FILE *fp2; /* second network file pointer */ BnetNetwork *net2 = NULL; /* second network */ DdManager *dd; /* pointer to DD manager */ int exitval; /* return value of Cudd_CheckZeroRef */ int ok; /* overall return value from main() */ int result; /* stores the return value of functions */ BnetNode *node; /* auxiliary pointer to network node */ int i; /* loop index */ int j; /* loop index */ double *signatures; /* array of signatures */ int pr; /* verbosity level */ int reencoded; /* linear transformations attempted */ /* Initialize. */ option = mainInit(); ntrReadOptions(argc,argv,option); pr = option->verb; reencoded = option->reordering == CUDD_REORDER_LINEAR || option->reordering == CUDD_REORDER_LINEAR_CONVERGE || option->autoMethod == CUDD_REORDER_LINEAR || option->autoMethod == CUDD_REORDER_LINEAR_CONVERGE; /* Currently traversal requires global BDDs. Override whatever ** was specified for locGlob. */ if (option->traverse == TRUE || option->envelope == TRUE || option->scc == TRUE) { option->locGlob = BNET_GLOBAL_DD; } /* Read the first network... */ fp1 = open_file(option->file1, "r"); net1 = Bnet_ReadNetwork(fp1,pr); (void) fclose(fp1); if (net1 == NULL) { (void) fprintf(stderr,"Syntax error in %s.\n",option->file1); exit(2); } /* ... and optionally echo it to the standard output. */ if (pr > 2) { Bnet_PrintNetwork(net1); } /* Read the second network... */ if (option->verify == TRUE || option->second == TRUE || option->clip > 0.0 || option->dontcares) { fp2 = open_file(option->file2, "r"); net2 = Bnet_ReadNetwork(fp2,pr); (void) fclose(fp2); if (net2 == NULL) { (void) fprintf(stderr,"Syntax error in %s.\n",option->file2); exit(2); } /* ... and optionally echo it to the standard output. */ if (pr > 2) { Bnet_PrintNetwork(net2); } } /* Initialize manager. We start with 0 variables, because ** Ntr_buildDDs will create new variables rather than using ** whatever already exists. */ dd = startCudd(option,net1->ninputs); if (dd == NULL) { exit(2); } /* Build the BDDs for the nodes of the first network. */ result = Ntr_buildDDs(net1,dd,option,NULL); if (result == 0) { exit(2); } /* Build the BDDs for the nodes of the second network if requested. */ if (option->verify == TRUE || option->second == TRUE || option->clip > 0.0 || option->dontcares == TRUE) { char *nodesave = option->node; option->node = NULL; result = Ntr_buildDDs(net2,dd,option,net1); option->node = nodesave; if (result == 0) { exit(2); } } if (option->noBuild == TRUE) { Bnet_FreeNetwork(net1); if (option->verify == TRUE || option->second == TRUE || option->clip > 0.0) { Bnet_FreeNetwork(net2); } freeOption(option); exit(0); } if (option->locGlob != BNET_LOCAL_DD) { /* Print the order before the final reordering. */ (void) printf("Order before final reordering\n"); result = Bnet_PrintOrder(net1,dd); if (result == 0) exit(2); } /* Perform final reordering */ if (option->zddtest == FALSE) { result = reorder(net1,dd,option); if (result == 0) exit(2); /* Print final order. */ if ((option->reordering != CUDD_REORDER_NONE || option->gaOnOff) && option->locGlob != BNET_LOCAL_DD) { (void) printf("New order\n"); result = Bnet_PrintOrder(net1,dd); if (result == 0) exit(2); } /* Print the re-encoded inputs. */ if (pr >= 1 && reencoded == 1) { for (i = 0; i < net1->npis; i++) { if (!st_lookup(net1->hash,net1->inputs[i],&node)) { exit(2); } (void) fprintf(stdout,"%s:",node->name); Cudd_PrintDebug(dd,node->dd,Cudd_ReadSize(dd),pr); } for (i = 0; i < net1->nlatches; i++) { if (!st_lookup(net1->hash,net1->latches[i][1],&node)) { exit(2); } (void) fprintf(stdout,"%s:",node->name); Cudd_PrintDebug(dd,node->dd,Cudd_ReadSize(dd),pr); } if (pr >= 3) { result = Cudd_PrintLinear(dd); if (result == 0) exit(2); } } } /* Verify (combinational) equivalence. */ if (option->verify == TRUE) { result = Ntr_VerifyEquivalence(dd,net1,net2,option); if (result == 0) { (void) printf("Verification abnormally terminated\n"); exit(2); } else if (result == -1) { (void) printf("Combinational verification failed\n"); } else { (void) printf("Verification succeeded\n"); } } /* Traverse if requested and if the circuit is sequential. */ result = Ntr_Trav(dd,net1,option); if (result == 0) exit(2); /* Traverse with trasitive closure. */ result = Ntr_ClosureTrav(dd,net1,option); if (result == 0) exit(2); /* Compute outer envelope if requested and if the circuit is sequential. */ if (option->envelope == TRUE && net1->nlatches > 0) { NtrPartTR *T; T = Ntr_buildTR(dd,net1,option,option->image); result = Ntr_Envelope(dd,T,NULL,option); Ntr_freeTR(dd,T); } /* Compute SCCs if requested and if the circuit is sequential. */ result = Ntr_SCC(dd,net1,option); if (result == 0) exit(2); /* Test Constrain Decomposition. */ if (option->partition == TRUE && net1->nlatches > 0) { NtrPartTR *T; DdNode *product; DdNode **decomp; int sharingSize; T = Ntr_buildTR(dd,net1,option,NTR_IMAGE_MONO); decomp = Cudd_bddConstrainDecomp(dd,T->part[0]); if (decomp == NULL) exit(2); sharingSize = Cudd_SharingSize(decomp, Cudd_ReadSize(dd)); (void) fprintf(stdout, "Decomposition Size: %d components %d nodes\n", Cudd_ReadSize(dd), sharingSize); product = Cudd_ReadOne(dd); Cudd_Ref(product); for (i = 0; i < Cudd_ReadSize(dd); i++) { DdNode *intermediate = Cudd_bddAnd(dd, product, decomp[i]); if (intermediate == NULL) { exit(2); } Cudd_Ref(intermediate); Cudd_IterDerefBdd(dd, product); product = intermediate; } if (product != T->part[0]) exit(2); Cudd_IterDerefBdd(dd, product); for (i = 0; i < Cudd_ReadSize(dd); i++) { Cudd_IterDerefBdd(dd, decomp[i]); } FREE(decomp); Ntr_freeTR(dd,T); } /* Test char-to-vect conversion. */ result = Ntr_TestCharToVect(dd,net1,option); if (result == 0) exit(2); /* Test extraction of two-literal clauses. */ result = Ntr_TestTwoLiteralClauses(dd,net1,option); if (result == 0) exit(2); /* Test BDD minimization functions. */ result = Ntr_TestMinimization(dd,net1,net2,option); if (result == 0) exit(2); /* Test density-related functions. */ result = Ntr_TestDensity(dd,net1,option); if (result == 0) exit(2); /* Test decomposition functions. */ result = Ntr_TestDecomp(dd,net1,option); if (result == 0) exit(2); /* Test cofactor estimation functions. */ result = Ntr_TestCofactorEstimate(dd,net1,option); if (result == 0) exit(2); /* Test BDD clipping functions. */ result = Ntr_TestClipping(dd,net1,net2,option); if (result == 0) exit(2); /* Test BDD equivalence and containment under DC functions. */ result = Ntr_TestEquivAndContain(dd,net1,net2,option); if (result == 0) exit(2); /* Test BDD Cudd_bddClosestCube. */ result = Ntr_TestClosestCube(dd,net1,option); if (result == 0) exit(2); /* Test ZDDs if requested. */ if (option->stateOnly == FALSE && option->zddtest == TRUE) { result = Ntr_testZDD(dd,net1,option); if (result == 0) (void) fprintf(stdout,"ZDD test failed.\n"); result = Ntr_testISOP(dd,net1,option); if (result == 0) (void) fprintf(stdout,"ISOP test failed.\n"); } /* Compute maximum flow if requested and if the circuit is sequential. */ if (option->maxflow == TRUE && net1->nlatches > 0) { result = Ntr_maxflow(dd,net1,option); if (result == 0) (void) fprintf(stdout,"Maxflow computation failed.\n"); } /* Compute shortest paths if requested and if the circuit is sequential. */ if (option->shortPath != NTR_SHORT_NONE && net1->nlatches > 0) { result = Ntr_ShortestPaths(dd,net1,option); if (result == 0) (void) fprintf(stdout,"Shortest paths computation failed.\n"); } /* Compute output signatures if so requested. */ if (option->signatures) { (void) printf("Positive cofactor measures\n"); for (i = 0; i < net1->noutputs; i++) { if (!st_lookup(net1->hash,net1->outputs[i],&node)) { exit(2); } signatures = Cudd_CofMinterm(dd, node->dd); if (signatures) { (void) printf("%s:\n", node->name); for (j = 0; j < Cudd_ReadSize(dd); j++) { if((j%5 == 0)&&i) (void) printf("\n"); (void) printf("%5d: %-#8.4g ", j, signatures[j]); } (void) printf("\n"); FREE(signatures); } else { (void) printf("Signature computation failed.\n"); } } } /* Dump BDDs if so requested. */ if (option->bdddump && option->second == FALSE && option->density == FALSE && option->decomp == FALSE && option->cofest == FALSE && option->clip < 0.0 && option->scc == FALSE) { (void) printf("Dumping BDDs to %s\n", option->dumpfile); if (option->node != NULL) { if (!st_lookup(net1->hash,option->node,&node)) { exit(2); } result = Bnet_bddArrayDump(dd,net1,option->dumpfile,&(node->dd), &(node->name),1,option->dumpFmt); } else { result = Bnet_bddDump(dd, net1, option->dumpfile, option->dumpFmt, reencoded); } if (result != 1) { (void) printf("BDD dump failed.\n"); } } /* Print stats and clean up. */ if (pr >= 0) { result = Cudd_PrintInfo(dd,stdout); if (result != 1) { (void) printf("Cudd_PrintInfo failed.\n"); } } #if defined(DD_DEBUG) && !defined(DD_NO_DEATH_ROW) (void) fprintf(dd->err,"%d empty slots in death row\n", cuddTimesInDeathRow(dd,NULL)); #endif (void) printf("Final size: %ld\n", Cudd_ReadNodeCount(dd)); /* Dispose of node BDDs. */ node = net1->nodes; while (node != NULL) { if (node->dd != NULL && node->type != BNET_INPUT_NODE && node->type != BNET_PRESENT_STATE_NODE) { Cudd_IterDerefBdd(dd,node->dd); } node = node->next; } /* Dispose of network. */ Bnet_FreeNetwork(net1); /* Do the same cleanup for the second network if it was created. */ if (option->verify == TRUE || option->second == TRUE || option->clip > 0.0 || option->dontcares == TRUE) { node = net2->nodes; while (node != NULL) { if (node->dd != NULL && node->type != BNET_INPUT_NODE && node->type != BNET_PRESENT_STATE_NODE) { Cudd_IterDerefBdd(dd,node->dd); } node = node->next; } Bnet_FreeNetwork(net2); } /* Check reference counts: At this point we should have dereferenced ** everything we had, except in the case of re-encoding. */ exitval = Cudd_CheckZeroRef(dd); ok = exitval != 0; /* ok == 0 means O.K. */ if (exitval != 0) { (void) fflush(stdout); (void) fprintf(stderr, "%d non-zero DD reference counts after dereferencing\n", exitval); } #ifdef DD_DEBUG Cudd_CheckKeys(dd); #endif Cudd_Quit(dd); if (pr >= 0) (void) printf("total time = %s\n", util_print_time(util_cpu_time() - option->initialTime)); freeOption(option); if (pr >= 0) util_print_cpu_stats(stdout); #ifdef MNEMOSYNE mnem_writestats(); #endif exit(ok); /* NOTREACHED */ } /* end of main */
int mainFenetre() { unsigned int frame_max = SDL_GetTicks() + FRAME_RATE, temps = 0; Input * pInput = NULL; //structure contenant les informations relatives aux inputs clavier SDL_Texture * pTextureDisplay = NULL; //Texture globale SDL_Rect camera = initRect(0, 0, 0, 0); // rect(x,y,w,h) Worms** wormsTab = NULL; char mapName[100]; Jeu* jeu = NULL; //init SDL + fenetre + renderer if (initSWR()) { //Initialisation des inputs pInput = initInput(); if (pInput == NULL) { fprintf(logFile, "mainFenetre : FAILURE, initInput.\n"); cleanUp(&pInput, &pTextureDisplay); return -1; } //InitSounds if (!initSDLMixer()){ fprintf(logFile, "initSDLMixer : FAILURE, init.\n"); cleanUp(&pInput, &pTextureDisplay); return -1; } strcpy(mapName, cMAP); /*Initialisation SDL_TTF*/ if (TTF_Init() == -1) { fprintf(logFile, "mainFenetre : FAILURE, initialisation de TTF_Init : %s.\n\n", TTF_GetError()); cleanUp(&pInput, &pTextureDisplay); return -1; } if (mainMenu(pInput, mapName) < 0) { fprintf(logFile, "mainFenetre : FAILURE, mainMenu .\n\n"); cleanUp(&pInput, &pTextureDisplay); return -1; } if (!pInput->quit) { if (mainInit() < 0) //set le nombre d'équipe et le nombre de worms par équipe { fprintf(logFile, "mainInit : FAILURE.\n"); cleanUp(&pInput, &pTextureDisplay); return -1; } /*Init game*/ jeu = nouveauJeu(mapName); if (jeu == NULL) { fprintf(logFile, "nouveauJeu : FAILURE.\n"); cleanUp(&pInput, &pTextureDisplay); return -1; } /*Init map*/ if (initialisionTerrain(&jeu->pMapTerrain, "../assets/pictures/FondMap1.png", jeu->nomMap) < 0) { fprintf(logFile, "mainFenetre : FAILURE, initialisationTerrain.\n"); cleanUp(&pInput, &pTextureDisplay); return -1; } /*Init global texture*/ pTextureDisplay = my_createTextureFromSurface(jeu->pMapTerrain->globalMapSurface); if (pTextureDisplay == NULL) { fprintf(logFile, "mainFenetre : FAILURE, createGlobalTexture.\n"); destroyMap(&jeu->pMapTerrain); cleanUp(&pInput, &pTextureDisplay); return -1; } /*Init sounds*/ if (loadSounds(BipExplo, 0) < 0) { fprintf(logFile, "mainFenetre : FAILURE, loadSounds.\n"); cleanUp(&pInput, &pTextureDisplay); return -1; } /*Init camera*/ initCameras(jeu->pMapTerrain, &camera, NULL); /*Initialisation du tableau global de worms*/ wormsTab = initWormsTab(jeu->equipes); if (wormsTab == NULL) { destroyMap(&jeu->pMapTerrain); cleanUp(&pInput, &pTextureDisplay); fprintf(logFile, "mainFenetre : FAILURE, allocating memory to the global array of worms pointer.\n\n"); return -1; } /*Init Display*/ initDisplay(jeu->pMapTerrain, pTextureDisplay); /*Initialisation des worms*/ while (!KaamInitGame(wormsTab, jeu->pMapTerrain->collisionMapSurface)) renderScreen(2, 0, jeu->pMapTerrain, 1, pTextureDisplay, &camera, NULL); } while (!(pInput->quit)) { //Récupération des inputs getInput(pInput); //Gestion des inputs if (!gestInput(pInput, jeu->pMapTerrain, pTextureDisplay, &camera, wormsTab)) { fprintf(logFile, "mainFenetre : FAILURE, gestInput.\n"); } //Update de l'écran if (pInput->raffraichissement) { renderScreen(2, 0, jeu->pMapTerrain, 1, pTextureDisplay, &camera, NULL); pInput->raffraichissement = 0; } updateTeamLife(jeu->equipes); isGameEnd(jeu->equipes); //Gestion du frame Rate frameRate(frame_max); frame_max = SDL_GetTicks() + FRAME_RATE; if ((SDL_GetTicks() - temps) >= 1000) { temps = SDL_GetTicks(); jeu->temps -= 1; } } endDisplay(); cleanSounds(); Mix_CloseAudio(); fprintf(logFile, "||| END OF THE GAME |||\n"); if (jeu != NULL) destroyMap(&jeu->pMapTerrain); destroyPolice(); if (wormsTab != NULL) free(wormsTab); wormsTab = NULL; } cleanUp(&pInput, &pTextureDisplay); fprintf(logFile, "mainFenetre : SUCCESS.\n"); if (jeu != NULL) { saveGame(jeu); destroyJeu(&jeu); } { time_t t1 = time(NULL); fprintf(logFile, "\n\nEnd of Session : %s", ctime(&t1)); fclose(logFile); }; return 0; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { char **argv, *p; int argc; char buffer[MAX_PATH]; setargv (&argc, &argv); /* * Replace argv[0] with full pathname of executable, and forward * slashes substituted for backslashes. */ GetModuleFileName(NULL, buffer, sizeof(buffer)); argv[0] = buffer; for (p = buffer; *p != '\0'; p++) { argv[0]; if (*p == '\\') { *p = '/'; } } mainInit(argc,argv); return 1; }