#include #include #include #include "ttr.h" int main(int argc, char **argv) { if (!has_colors) return 0; if (argc == 0) { return 0; } lcd_incolor(); // un peu de hasard srand(time(NULL)); uint8 joueurCourant = 0; uint8 slotCourant = 0; etatGlobal = ETAT_SPLASH_SCREEN; while (etatGlobal != ETAT_RETOUR_BUREAU) { switch (etatGlobal) { case ETAT_SPLASH_SCREEN: initGlobal(argv[0]); loadGrafx_file(); // afficher le splash screen uint32 taille = chargerTaille_file(FILE_TITLE_TTR); unsigned char *sprTtr = malloc(taille); chargerGrafx_file(sprTtr, FILE_TITLE_TTR, taille); afficherGrafx_bufferSlow(sprTtr,38,0,SCREEN_DIRECT, 0xFFFF); free(sprTtr); initAlphaBlending(); etatGlobal = ETAT_LOADING; break; case ETAT_LOADING: // charger les grafx loadGrafx_ram(); // les routes en mémoire creations_routes(); // la carte loadUsMap(); // les cartes missions initCartes(); // les joueurs initJoueurs(); etatGlobal = ETAT_MENU_ANIME; break; case ETAT_MENU_ANIME: afficherAnimationMenu(); etatGlobal = ETAT_MENU; break; case ETAT_MENU: etatGlobal = afficherMenuPrincipal(); break; case ETAT_NOUVELLE_PARTIE: etatGlobal = afficherNouvellePartie(); break; case ETAT_CHOIX_SLOT_SAUVEGARDE: etatGlobal = choisirSlot(false); break; case ETAT_CHOIX_SLOT_1: case ETAT_CHOIX_SLOT_2: case ETAT_CHOIX_SLOT_3: case ETAT_CHOIX_SLOT_4: case ETAT_CHOIX_SLOT_5: slotCourant = etatGlobal - ETAT_CHOIX_SLOT_1 + 1; etatGlobal = ETAT_LANCER_PARTIE; break; case ETAT_CHARGER_PARTIE: etatGlobal = choisirSlot(true); break; case ETAT_LANCER_PARTIE: preparerUsMap(); initPioches(); testerPassAndPlay(); joueurCourant = 1; numeroTour = 0; tourRestant = 0; etatGlobal = ETAT_CHOIX_JOUEUR; break; case ETAT_LOADING_SLOT_1: case ETAT_LOADING_SLOT_2: case ETAT_LOADING_SLOT_3: case ETAT_LOADING_SLOT_4: case ETAT_LOADING_SLOT_5: slotCourant = etatGlobal - ETAT_LOADING_SLOT_1 + 1; joueurCourant = chargerPartie(slotCourant); // mélanger les cartes pour éviter la triche ? testerPassAndPlay(); melangerPiocheWagon(); if (joueurCourant == 0) { etatGlobal = ETAT_FIN_DU_JEU; } else { etatGlobal = ETAT_CHOIX_JOUEUR; } break; case ETAT_CHOIX_JOUEUR: etatChoixJoueur(joueurCourant, slotCourant); break; case ETAT_FIN_DU_TOUR: // changer de joueur if (tourRestant > 0) { tourRestant--; if (tourRestant == 0) { etatGlobal = ETAT_FIN_DU_JEU; } } if (etatGlobal == ETAT_FIN_DU_TOUR) { joueurCourant ++; if (joueurCourant == nbTotalJoueur+1) { joueurCourant = 1; numeroTour++; } etatGlobal = ETAT_CHOIX_JOUEUR; } break; case ETAT_CHOIX_ROUTE: etatChoixRouteJoueur(joueurCourant, slotCourant); break; case ETAT_CHOISIR_CARTES_MISSIONS: etatChoixCarteMission(joueurCourant, slotCourant, false); break; case ETAT_FIN_DU_JEU: terminerPartie(slotCourant); afficherFinDuJeu(); etatGlobal = ETAT_MENU; break; case ETAT_CREDITS: afficherCredits(); etatGlobal = ETAT_MENU; break; case ETAT_TUTORIAL: afficherTuto(); etatGlobal = ETAT_MENU; break; case ETAT_LIBERATION_MEMOIRE: doneGlobal(); doneUsMap(); doneGrafx_ram(); doneGrafx_file(); doneJoueurs(); etatGlobal = ETAT_RETOUR_BUREAU; break; } } return 0; }